Using Find Function with If Function

MASONS4

New Member
Joined
Mar 4, 2009
Messages
21
Hi,

I'm trying to write some code, to search cells A33 to A100 to see if they contain the word "Holiday". If it does, I then need it to select the cell with holiday in (and ideally the cell next to is as well). Holiday will only appear once in the list if it is there at all.

My code writing is poor at best, but I'm unable to merge a "Find" with an "If".

Please see the below copy of my attempt:

Test = Range("A32:A100").Select

Set Test = Cells.Find(What:="Holiday", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

If Test Is Holiday Then

Test.Activate
ActiveCell.Select 'and the cell next to it (in column B)

End If

As I mentioned earlier, holiday will only appear once, and will not be in every search.

Many thanks for any helps.

Sean
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try:

Code:
Dim rng As Range
Set rng = Range("A32:A100").Find(What:="Holiday", LookIn:=xlValues)
If Not rng Is Nothing Then
    rng.Resize(1, 2).Select
End If
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

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