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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,213,551
Messages
6,114,273
Members
448,559
Latest member
MrPJ_Harper

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