我在 excel 中有一个表格,我正在插入一些列,因为最后一列正在更改,我必须检测最后一列并将其设置为 vba 中的范围
我已经编写了代码来查找最后一列并将其转换为字母,但是我无法将其设置为范围。
Public Function ColumnLetter(ColumnNumber As Long) As String
ColumnLetter = Split(Cells(1, ColumnNumber).Address(True, False), "$")(0)
End Function
Dim Rng As Range
Dim LastColumn, LastRow As Long
Dim Str As String
LastRow = Cells(Rows.Count, 2).End(xlUp).Row
LastColumn = Cells(2, Columns.Count).End(xlToLeft).Column
Str = ColumnLetter(LastColumn)
'Set Rng = Range("M7:M" & LastRow)
我想将注释行写为
Set Rng = Range( & Str & "7" & LastRow)
让它动态我该怎么做?