我想创建一个VBA子例程,在表中搜索名为“Phonetic Name”的第一个列 Headers . 然后在右下角找到表中的绝对最后一个单元格,并将变量存储为最后一个单元格上方一行的单元格坐标 . 然后子程序将选择第一个单元“Phonetic Name”和“LastCell”变量之间的所有单元 .
Dim LastCol As Integer
TL = ActiveSheet.Range("A:A").Find("Phonetic Name", LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True).Row
Set LastRow = Cells.Find("*", [a1], , , xlByRows, xlPrevious)
With ActiveSheet
LastCol = .Cells(TL, .Columns.Count).End(xlToLeft).Column
End With
Set LastCell = ActiveSheet.Cells(LastRow.Row - 1, LastCol)
'I would like to do something like the following...
ActiveSheet.Range("TL:LastCell").Select
Selection.Copy
如何以VBA友好的方式重写此逻辑?
1 回答