EJECUTAR MACRO EN GRUPO DE 6

1 post / 0 nuevos
dgiufre
Imagen de dgiufre
Offline
última acción: Hace 4 años 3 meses
alta: 22/05/2019 - 18:09
Puntos: 75
EJECUTAR MACRO EN GRUPO DE 6

Tengo el siguiente código de autoría de Dante Amor pero necesito hacer una modificación, dicho código compara 30 filas de números entre si y los resultados los copia en la hoja2, necesito que haga exactamente lo mismo pero en grupos de 6,

 

De fila 1 a la 6 y copie los resultados en la hoja 2

 

De fila 7 a la 12 a continuación en la hoja 2

 

De fila 13 a la 18 ídem

 

De fila 19 a la 24 ídem

 

De fila 25 a la 30 ídem

 

Sub CompararDatos()

'Por.Dante Amor

Application.ScreenUpdating = False

Set h1 = Sheets("Hoja1")

Set h2 = Sheets("Hoja2")

h2.Cells.Clear

n = 0

For i = 1 To 30

For j = Columns("D").Column To Columns("W").Column

Set r = h1.Range("D1:W30")

Set b = r.Find(h1.Cells(i, j), lookat:=xlWhole)

If Not b Is Nothing Then

celda = b.Address

Do

If b.Row <> i Then

h2.Cells(b.Row + n, j) = b.Value

End If

Set b = r.FindNext(b)

Loop While Not b Is Nothing And b.Address <> celda

End If

Next

h2.Rows(i + n).Delete

If wcol = 4 Then wcol = 6 Else wcol = 4

h2.Range(h2.Cells(n + 1, "D"), h2.Cells(n + 29, "W")).Interior.ColorIndex = wcol

n = n + 29

Next

End Sub