Macros sumar y contar entre dos fechas y un criterio
Publicado por Ana Karen (7 intervenciones) el 04/05/2021 16:56:21
necesito incorporar a la siguiente macros la suma del apartado de la imagen,
Se tienen que sumar los criterios AGUAS, LIMPIEZAS, PREMIO PESO, BÁSCULAS que se encuentran en la hoja Formato cuentas tobe, dependiendo del criterio ubicado en la celda A5 y las fechas ubicadas en F4 y F5, los datos a sumar se encuentran en la hoja Rutas diarias Tobe
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
Sub consulta()
Dim hoja_origen As String
Dim hoja_destino As String
hoja_origen = "RUTAS DIARIAS TOBE"
hoja_destino = "FORMATO CUENTAS TOBE"
Dim clave_aux As String
Dim clave_viaje As String
Dim ruta As String
Dim ultimafilaorigen As Long
Dim aux As Long
Dim count As Long
Dim palabra As String
Dim Fecha_Inico As Long, _
Fecha_Final As Long
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
Fecha_Inici = Sheets(hoja_destino).Cells(4, "F")
Fecha_Final = Sheets(hoja_destino).Cells(5, "F")
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
If Sheets(hoja_origen).Cells(count, "E") >= Fecha_Inici And _
Sheets(hoja_origen).Cells(count, "E") <= Fecha_Final Then
Rows(inicial).EntireRow.Insert
Sheets(hoja_destino).Cells(inicial, 1) = Sheets(hoja_origen).Cells(count, 10) ' - cantidad
Sheets(hoja_destino).Cells(inicial, 2) = Sheets(hoja_origen).Cells(count, 2) ' - clave_aux
Sheets(hoja_destino).Cells(inicial, 3) = palabra & clave_aux ' - clave
Sheets(hoja_destino).Cells(inicial, 4) = Sheets(hoja_origen).Cells(count, 5) ' - fecha
Sheets(hoja_destino).Cells(inicial, 5) = Sheets(hoja_origen).Cells(count, 16) ' - tarifaUnitaria
Sheets(hoja_destino).Cells(inicial, 6) = Sheets(hoja_origen).Cells(count, 16) ' - total
inicial = inicial + 1
End If
End If
Next count
End Sub
- Cuentas-Operadores-1.zip(75,8 KB)
Valora esta pregunta
0