Using .Find

JSA715

Active Member
Joined
Aug 3, 2008
Messages
254
According to the help in the excel IDE, .Find returns a range object.

So, why instead of getting a range, it appears to return the value I am searching for?

Code:
Dim rFound as Range
Dim iBr as Integer
iBr = 3
          With WB.Sheets("GL Transaction Totals - MTD and YTD")
          Set rFound = .Range("C6:C20000").Find(iBr, LookIn:=xlValues, lookat:=xlWhole)

rFound = 3??
iBr is an interger
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
It does return a range (provided it finds a match). 3 will be the value in the cell it's found. Note, you are using the Set keyword and you declared rFound as a Range.
 
Upvote 0
Hey Colin,

Thanks for the reply.

Well I declared it as a range and used set because I want to the reference the range in another expression down the road. However, "3" isnt a range. How would I set the rFound to the address of the expression?
 
Upvote 0
Hi,

3 is value in the cell that was found.

To get the address:

Code:
Dim rFound as Range
Dim iBr as Integer
iBr = 3
          With WB.Sheets("GL Transaction Totals - MTD and YTD")
          Set rFound = .Range("C6:C20000").Find(iBr, LookIn:=xlValues, lookat:=xlWhole)
          If Not rFound Is Nothing Then MsgBox rFound.Address

Hope that helps...
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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