Supongamos que tenemos estas tres columnas con datos

Queremos que los datos se muestren en la columna D unos detrás de otros. Es decir, primero la columna A, luego la B y luego la C.
- Para ello, abrimos el editor (alt+F11) y escribimos el siguiente código en la hoja correspondiente:
Sub CombinarColumnas()
Columns("A").Copy Destination:=Columns("D")
NewRowD = Range("D" & Rows.Count).End(xlUp).Row + 1
LastRowB = Range("B" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("B1:B" & LastRowB)
CopyRange.Copy Destination:=Range("D" & NewRowD)
NewRowD = Range("D" & Rows.Count).End(xlUp).Row + 1
LastRowC = Range("C" & Rows.Count).End(xlUp).Row
Set CopyRange = Range("C1:C" & LastRowC)
CopyRange.Copy Destination:=Range("D" & NewRowD)
End Sub
Tal y como vemos en la imagen

- Ejecutamos la macro haciendo clic en Ejecutar o bien pulsando F5

El resultado es el siguiente

0 comentarios:
Publicar un comentario