Macros para fechas
Publicado por Ana Karen (7 intervenciones) el 30/04/2021 20:34:41
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//Se necesita implementar en la siguiente macros un filtro de fecha inicio y fecha final
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$5" Then
Call consulta
End If
End Sub
Sub consulta()
Dim hoja_origen As String
Dim hoja_destino As String
hoja_origen = "RUTAS DIARIAS TOBE"
hoja_destino = "FORMATO CUENTAS TOBE"
Dim cantidad As String
Dim clave As String
Dim clave_aux As String
Dim clave_viaje As String
Dim fecha As String
Dim tarifaUnitaria As String
Dim ruta As String
Dim total As String
Dim ultimafilaorigen As Long
Dim aux As Long
Dim count As Long
Dim palabra As String
palabra = Sheets(hoja_destino).Cells(5, 1)
inicial = 12
condicion = Sheets(hoja_destino).Cells(inicial, 1)
Do Until (condicion Like "END")
Rows(inicial).EntireRow.Delete
condicion = Sheets(hoja_destino).Cells(inicial, 1)
Loop
ultimafilaorigen = Sheets(hoja_origen).Range("A" & Rows.count).End(xlUp).Row
For count = 2 To ultimafilaorigen
If Sheets(hoja_origen).Cells(count, 1) Like palabra Then
Rows(inicial).EntireRow.Insert
cantidad = Sheets(hoja_origen).Cells(count, 10)
clave_aux = Sheets(hoja_origen).Cells(count, 2)
clave = palabra & clave_aux
fecha = Sheets(hoja_origen).Cells(count, 5)
tarifaUnitaria = Sheets(hoja_origen).Cells(count, 16)
total = Sheets(hoja_origen).Cells(count, 16)
Sheets(hoja_destino).Cells(inicial, 1) = cantidad
Sheets(hoja_destino).Cells(inicial, 2) = clave_aux
Sheets(hoja_destino).Cells(inicial, 3) = clave
Sheets(hoja_destino).Cells(inicial, 4) = fecha
Sheets(hoja_destino).Cells(inicial, 5) = tarifaUnitaria
Sheets(hoja_destino).Cells(inicial, 6) = total
inicial = inicial + 1
End If
Next count
End Sub
- Cuentas-Operadores-1.rar(69,5 KB)
Valora esta pregunta


0