I am trying to improve a bad habit of using For loops to loop trough a column to find the a value so that can use the row number in other parts of my code. I would like some input if the soluon I have found is the most efficient way to accomplish this.
This is my new solution. Is this the most efficient way to accomplish what I am tryng to do?
Please let me know if you have a better way. Would it matter if I used a shorter range, like "A1:A1000"?
This is my new solution. Is this the most efficient way to accomplish what I am tryng to do?
Code:
Dim SearchVal As Variant
Dim CheckRange As Range
Dim RowNum As Long
Set CheckRange = Columns("A:A")
SearchVal = "test1"
On Error Resume Next
RowNum = Application.WorksheetFunction.Match(SearchVal, CheckRange, 0)
On Error GoTo 0
MsgBox RowNum
Please let me know if you have a better way. Would it matter if I used a shorter range, like "A1:A1000"?