如何在特定标题的列右侧插入3个新列。以下是我的初始代码:
Sub InsertColumn()
Dim DischargeDate As Range
Set DischargeDate = Range("A1:BV1").Find("DISCHARGE DATE")
If DischargeDate Is Nothing Then
MsgBox "DISCHARGE DATE column was not found."
Exit Sub
End If
' If DISCHARGE DATE was found in the column "AD", insert new column on this range example:
' Range("AE:AG").EntireColumn.Insert
- >我在这里使用的范围应该是什么,因为DISCHARGE DATE有时不在“AD”中的列
End Sub
我希望我的问题很明确。谢谢!
答案 0 :(得分:1)
试试这个:
Sub InsertColumn()
Dim DischargeDate As Range
Set DischargeDate = Range("A1:BV1").Find("DISCHARGE DATE")
If DischargeDate Is Nothing Then
MsgBox "DISCHARGE DATE column was not found."
Exit Sub
Else
Columns(DischargeDate.Column).Offset(, 1).Resize(, 3).Insert
End If
End Sub