0

So I am trying to find the row number of a cell which contains the value “SOI 1”. The message box returns the correct number, but when I try to assign that number to a variable for later use I get the compile error:

“Wrong number of arguments or invalid property assignment”

I’m fairly new to VBA, so any help you guys can provide would be amazing!

Public Sub Testing()

Dim rFind As Range
Dim row_SOI1 As Integer

test = "SOI 1"

With Range("A1:A100")
Set rFind = .Find(What:="SOI 1", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
If Not rFind Is Nothing Then
    MsgBox rFind.Row
    If test = "SOI 1" Then:
        rFind.Row = row_SOI1
    End If
End If
End With

End Sub
Community
  • 1
  • 1
Goggles998
  • 23
  • 5
  • I think you want this `row_SOI1 = rFind.Row` – Storax Apr 11 '18 at 08:41
  • You are right! Thank you! Good ol’ VBA syntax... – Goggles998 Apr 11 '18 at 08:48
  • Note: Don't use `Integer` for row counting. Excel has more rows than `Integer` can handle. Always use `Long` instead of `Integer` there is [no benefit in using `Integer` in VBA at all](https://stackoverflow.com/a/26409520/3219613). – Pᴇʜ Apr 11 '18 at 08:49

0 Answers0