.find within a range.

vbaNewby

Board Regular
Joined
Jan 26, 2011
Messages
138
Hello everyone,

I need help on looping through a range and finding a value. My code:
Code:
MsgBox foundsub.Address
Set foundsub = foundsub.Resize(1000, 1000)
With foundsub
                                Set FoundCell = .Find(What:=myCell, _
                                                    After:=.Cells(.Cells.count), _
                                                    LookIn:=xlValues, _
                                                    LookAt:=xlWhole, _
                                                    SearchOrder:=xlByRows, _
                                                    SearchDirection:=xlNext, _
                                                    MatchCase:=False)
                            End With
                            If FoundCell Is Nothing Then
                                MsgBox "Didn't find"
                            End If
myCell is a string that I am searching for. I set foundsub somewhere else, resize it and then use it to try and find myCell. I know foundsub is being found and resized but for some reason FoundCell is being set to nothing and I get back "Didn't find"

Also, I know that the string myCell is within the range but it is still returning nothing.

Help!

Thanks in advance
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,603
Messages
6,179,854
Members
452,948
Latest member
UsmanAli786

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