Using Control F in VBA

reuben9000

New Member
Joined
Feb 8, 2015
Messages
6
Hi!

So I'm a noob to Macros and I was just sort of self learning Excel to sort of get better at my job. I decided to write a macro to make my life easier.

I have one question which will make my life much easier - If I use a Control F while recording a Macro to find data which is present in a particular cell and then select the cell, the macro only records that I selected that exact cell instead of the fact that I selected the cell containing the string that I searched for.
For example if I searched for "Hello" which is present in cells A1, B7 and C8; even though I select the cell after using Cntrl F while I record the Macro, Excel will go to exactly to A1, B7 and C8 when I run the Macro instead of the cells that contain the word Hello

Can someone please help me solve this problem? I understand it might nbe quite basic, but I'm very new to coding so any help will be appreciated.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
When I used Ctrl-F, this is what the Macro Recorder recorded

Code:
 Cells.Find(What:="cat", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
        .Activate
    Cells.FindNext(After:=ActiveCell).Activate
    Cells.FindNext(After:=ActiveCell).Activate
    Cells.FindNext(After:=ActiveCell).Activate
 
Upvote 0

Forum statistics

Threads
1,223,238
Messages
6,170,939
Members
452,368
Latest member
jayp2104

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