是否可以在一个驱动器中使用自动化来重组多个 header 一个驱动器 table?

Is it possible to restructure multi header one drive table using automate in one drive?

我正在尝试使用自动化功能在一个驱动器内部进行重构,但不确定是否可以重构多个 header table。预先感谢您的帮助。

我想以这种格式重组它 -

客户

您可以遍历第一行中的日期并创建一个嵌套循环,一个一个地遍历客户,并根据实际的列和行获取值。您应该将结果保存在新的 sheet.

Sub Format_Table()
    lastRowOnNewFormatSheet = 2 'last empty row on newSheet
    'Loop through the columns with step 3
    For i = 2 To Cells(1, Columns.Count).End(xlToLeft).Column Step 3
        'Loop through the rows at every column
        For j = 3 To Cells(Rows.Count, 1).End(xlUp).Row
            Sheets("newFormat").Cells(lastRowOnNewFormatSheet, 1).Value = Sheets("oldFormat").Cells(j, 1) 'customer name
            Sheets("newFormat").Cells(lastRowOnNewFormatSheet, 2).Value = Sheets("oldFormat").Cells(1, i) 'date
            Sheets("newFormat").Cells(lastRowOnNewFormatSheet, 3).Value = Sheets("oldFormat").Cells(j, i) 'budget
            Sheets("newFormat").Cells(lastRowOnNewFormatSheet, 4).Value = Sheets("oldFormat").Cells(j, i + 1) 'actual
            lastRowOnNewFormatSheet = lastRowOnNewFormatSheet + 1 'update last empty row on newSheet
        Next j
    Next i
End Sub