Transponga varias columnas a varias filas con VBA
Este tipo de transformación es lo que estaba tratando de realizar. Solo a modo de ilustración, he hecho esto como tabla, por lo que básicamente las primeras 3 columnas deberían repetirse para cuántos colores hay disponibles.
Busqué otros tipos similares pero no pude encontrar cuando quiero que se repitan varias columnas. Encontré este código en línea, pero es Name Thank Location Thank Location Thank Location Thank Location y hace que se muestre a continuación
Sub createData()
Dim dSht As Worksheet
Dim sSht As Worksheet
Dim colCount As Long
Dim endRow As Long
Dim endRow2 As Long
Set dSht = Sheets("Sheet1") 'Where the data sits
Set sSht = Sheets("Sheet2") 'Where the transposed data goes
sSht.Range("A2:C60000").ClearContents
colCount = dSht.Range("A1").End(xlToRight).Column
'// loops through all the columns extracting data where "Thank" isn't blank
For i = 2 To colCount Step 2
endRow = dSht.Cells(1, i).End(xlDown).Row
For j = 2 To endRow
If dSht.Cells(j, i) <> "" Then
endRow2 = sSht.Range("A50000").End(xlUp).Row + 1
sSht.Range("A" & endRow2) = dSht.Range("A" & j)
sSht.Range("B" & endRow2) = dSht.Cells(j, i)
sSht.Range("C" & endRow2) = dSht.Cells(j, i).Offset(0, 1)
End If
Next j
Next i
End Sub
¿Podría alguien ayudarme a cambiar el formato que quiero? Intenté cambiar el paso 2 a 1 y j para comenzar desde 4, pero eso no fue útil Otro, por ejemplo, con 2 conjuntos variados: