我有一个变量startingRow
startingRow = 36
我想使用Cells.Find函数来搜索第36行之后的第一行。我该如何做到这一点?
foundRow = wksDreamSheet.Cells.Find("Summa/Snitt", 36, , , xlByRows, xlNext).Row
答案 0 :(得分:2)
试试这个:
startingRow = 36
With wksDreamSheet
Set rng = .Range(startingRow & ":" & .Rows.Count).Find("Summa/Snitt", , , , xlByRows, xlNext)
End With
或更可靠:
Dim rng As Range
startingRow = 36
With wksDreamSheet
Set rng = .Range(startingRow & ":" & .Rows.Count).Find("Summa/Snitt", , , , xlByRows, xlNext)
End With
If Not rng Is Nothing Then
foundRow = rng.Row
Else
foundRow = 1 ' or any other number (or msgbox with error)
End If