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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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