VBA – 查找特定范围的列的最后一行

这一定很简单,但是我找不到任何地方。

我有一个表格,范围从“A:EV”。

我想find范围“A:DD”的最后一行。

列可能有空单元格,所以我需要通过所有,find列A到DD的最远行。

我如何编码?

从这里修改

Sub foo() With Sheets("Sheet9") 'Change to your sheet If Application.WorksheetFunction.CountA(.Cells) <> 0 Then lastrow = .Range("A:DD").Find(What:="*", _ After:=.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row Else 'Used 1000 to prove that it was not defaulting to this. 'Change to 1 when using in actual code. lastrow = 1000 'Change to 1 when using. End If MsgBox lastrow End With End Sub 

在这里输入图像说明