0
我想要做的是編寫一個VB宏,它將掃描整個列(列F)灼熱爲「Year Total:」,然後插入一個整行在它下面。在excel中查找某個值並在其下面添加整行使用Vbscript
我有這樣的:
子Macro2() ' ' Macro2宏 ' ' 快捷鍵:Ctrl +一
Dim C As Variant
Dim FirstRow As Integer
With Worksheets(1).Range("F1:F4000")
Set C = .Find("Year Total:", LookIn:=xlValues)
If Not C Is Nothing Then
FirstRow = C.Row
Do
C.Offset(1, 0).Insert Shift:=xlDown
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Row <> FirstRow
End If
End With
結束子
然而,它只會增加細胞,而不是整行。
我還想添加到代碼中,因爲它還在同一列中搜索「Grand Total:」,並在其下添加三行。我只是要寫兩個腳本,但是如果我可以將它們混合在一起,那就太好了。