这就是我正在尝试执行的转换。
为了说明,我把它做成了桌子。基本上前三列应该重复,无论有多少颜色可用。

我搜索了类似的问题,但在我想要重复多列时找不到。
我在网上找到了这个代码
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) …Run Code Online (Sandbox Code Playgroud)