Use FIND to find a Row Number

Mackeral

Board Regular
Joined
Mar 7, 2015
Messages
237
Office Version
  1. 365
Platform
  1. Windows
VBA Code:
   With SHEET.Range("A3:A321")
        Hold = .Find(What:="Albany Tire", LookIn:=xlValues)
    End With    

    If Hold <> "" Then
        Answer_Row = Hold.Row '      Error on this line
        Answer_Col = Hold.Column'   Error on this line
    End If

This code use to work but doesn't now.
Cell("A23") contains "Albany Tire",
Both the "Answer" lines give errors now.

What's wrong? Many thanks.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try

Code:
If Not Hold Is Nothing Then
    Answer_Row = Hold.Row
    Answer_Col = Hold.Column
End If
 
Upvote 0
Can't see how that code would have worked without the word Set, without seeing the rest of the code try...
VBA Code:
   With SHEET.Range("A3:A321")
         Set Hold = .Find(What:="Albany Tire", LookIn:=xlValues)
    End With

    If Not Hold Is Nothing Then
        Answer_Row = Hold.Row                    '      Error on this line
        Answer_Col = Hold.Column                 '   Error on this line
    End If
 
Upvote 0
Thank you for your replies, but neither of them made my code work.
 
Upvote 0
Then you need to post your full code and an XL2BB of your data

Below is a link to a workbook with the code I previously posted (with a few variable declarations and message boxes) that works for me

 
Upvote 0
Also is Albany Tire the only text in the cell?
 
Upvote 0
Yes' "Albany Tires" is what is in cell("A23").
 
Upvote 0
If that is the only text in A23 then as I stated you need to post your full code and an XL2BB of your data
 
Upvote 0
My correction: "Albany Tire" is what is in the lookup Sheet. So why isn't it found. It was before VBA got changed.
And I have downloaded "XL2BB"but can't read it> Errmsg says "
Mac
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,721
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top