Dim lastrow as Integer, val
lastrow = Range("B" & Rows.Count).End(xlUp).Row
val = range("B" & lastrow + 2).Value
遍历不为空的行(标题)是另一回事,您可以轻松搜索了解。
Dim svVal As String
svVal = "SVC525" '<--| set your header value to be searched for in row 1
With Worksheets("averages") '<--| change "Averages" tou your actual sheet name
MsgBox .Cells(.Rows.count, .Range("A1", .Cells(1, .Columns.count).End(xlToLeft)).Find(what:=svVal, LookIn:=xlValues, lookat:=xlWhole).column).End(xlUp)
End With
Cells(Rows.Count, x).End (xlUp)
。您应该观看WiseOwlTutorials的Excel VBA Introduction Part 5 - Selecting Cells (Range, Cells, Activecell, End, Offset)。 - user6432984