我想在整个电子表格中重复插入一个列表(下面:生成器,控制塔等)。它应该每隔一行(每个涡轮机后)插入并偏移一列,如下所示。我不知道如何编写宏来自动执行此操作。任何帮助表示赞赏。
TURBINE A-2
Generator
Control Tower
Brakes
Pitch System
Hydraulic System
Cooling System
Oil Filtration System
Lighting System
Ascent System
Scada Systems
Nacelle Cover
Cable System
Fire System
Blades
TURBINE A-3
Generator
Control Tower
Brakes
Pitch System
Hydraulic System
Cooling System
Oil Filtration System
Lighting System
Ascent System
Scada Systems
Nacelle Cover
Cable System
Fire System
Blades
TURBINE A-4
TURBINE A-5
TURBINE A-6
TURBINE A-7
答案 0 :(得分:0)
这应该可以解决问题:
Public Sub AddEntries()
Dim InsertionRange As Range
Dim HeaderRow As Integer
Dim RowIndex As Integer
Const ListSize = 14
Dim ListEntries(1 To ListSize) As String
ListEntries(1) = "Generator"
ListEntries(2) = "Control Tower"
ListEntries(3) = "Brakes"
ListEntries(4) = "Pitch System"
ListEntries(5) = "Hydraulic System"
ListEntries(6) = "Cooling System"
ListEntries(7) = "Oil Filtration System"
ListEntries(8) = "Lighting System"
ListEntries(9) = "Ascent System"
ListEntries(10) = "Scada Systems"
ListEntries(11) = "Nacelle Cover"
ListEntries(12) = "Cable System"
ListEntries(13) = "Fire System"
ListEntries(14) = "Blades"
HeaderRow = 1
While (Cells(HeaderRow, 1).Value <> "")
Rows(Trim$(Str$(HeaderRow + 1)) & ":" & Trim$(Str$(HeaderRow + ListSize))).Insert shift:=xlDown
For RowIndex = 1 To ListSize
Cells(RowIndex + HeaderRow, 2).Value = ListEntries(RowIndex)
Next RowIndex
HeaderRow = HeaderRow + ListSize + 1
Wend
End Sub
我假设TURBINE条目都在excel文件的第一列。