如何从特定范围的列中获取最后一行

我有一些代码打开Excel电子表格,并获取该列中的最后一个空行。 我遇到的问题是我在我的Excel电子表格中创build了两个表格。 我想只能selectB7:B94的列B的范围,因为我有代表从B开始的另一个表的数据:101这是我的代码到目前为止…

Const xlUp = -4162 Set xlApp = CreateObject("Excel.Application") With xlApp .Visible = False Set xlWB = .Workbooks.Open("M:\Shared Documents\Job Cost Analysis\Hi-Tech BPO\Logs\" & currentMonth & "-Summary Hi Tech BPO.xlsx", , False) Set ws = .Worksheets(sheetName) Dim LR '''''''''''Here is where I want to select the range of B7:B94'''''''''''''' LR = .Range("B" & .Rows.count).End(xlUp).Row .Range("B" & LR + 1).Value = RIGHT(client_id,LEN(client_id)-7) End With xlApp.DisplayAlerts = False xlWB.SaveAs ("M:\Shared Documents\Job Cost Analysis\Hi-Tech BPO\Logs\" & currentMonth & "-Summary Hi Tech BPO.xlsx") xlWB.Close xlApp.Quit 

对于非结构化的数据块,

 LR = .Range("B100").End(xlUp).Row 

对于真正的ListObject (又名结构化 )表,

 LR = .Range("B100").End(xlUp).End(xlUp).Row 

后者假定桌子不是“满的”。 应该确保LR不是7。

怎么样

 .Range("B7").End(xlDown).Offset(1,0).Row