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.
 

Some videos you may like

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,849
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
 

Watch MrExcel Video

Forum statistics

Threads
1,119,247
Messages
5,576,940
Members
412,753
Latest member
Coach_Olson
Top