+ Reply to Thread
Results 1 to 7 of 7

VBA to give the ctrl-F (find) function

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    wales
    MS-Off Ver
    Excel 2010
    Posts
    64

    VBA to give the ctrl-F (find) function

    I am looking for help is there is a vba function to do exactly what the ctrl-f (find function)

    I am looking for a macro that will bring up the find box and default to search the entire workbook. I want to then type in the string and find all for it to display all locations in the workbook where the string exists

    any help would be appreciated

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA to give the ctrl-F (find) function

    You can use .find to do the ctrl-f (this is what you will get if you use the macro recorder but I don't think you can use the find all part of it from vba). You would probably need to loop through to find all occurences. How would you want it to be displayed?

    To start you off:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-14-2013
    Location
    wales
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: VBA to give the ctrl-F (find) function

    Thanks for the quick reply. I would like to display the results in a box showing all locations in every worksheet within the workbook. ideally I would like to click then to goto all of these but could be dreaming. Basically I would like to launch the excel find window with the search defaulted to search the entire workbook if possible . hence drive the ctrl F function request

    many thanks
    mark

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA to give the ctrl-F (find) function

    Normally I wouldn't recommend using sendkeys but in this instance it might be an option:
    Please Login or Register  to view this content.
    Alternatively, have a look here: www.cpearson.com/excel/findall.aspx

  5. #5
    Registered User
    Join Date
    02-14-2013
    Location
    wales
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: VBA to give the ctrl-F (find) function

    Finally solved using keystrokes as suggested

    here is the code
    Sub Find()
    '
    ' Keystrokes to Open Find Windows & Select to Search Entire Workbook
    SendKeys "^f", Wait ' CTRL & F (Find)
    SendKeys "%t", Wait ' Alt & T (Options)
    SendKeys "%h", Wait ' Alt & H (Within)
    SendKeys "w", Wait ' W (Select Workbook from Drop Down)
    SendKeys "{enter}", Wait ' ENTER (To Select Workbook)
    SendKeys "%N", Wait ' Alt & N (Select Find What Field)
    SendKeys "{delete}" ' Delete (To Clear the Field ready for Input)
    '
    End Sub

  6. #6
    Registered User
    Join Date
    05-29-2020
    Location
    Michigan, United States
    MS-Off Ver
    Office 365
    Posts
    1

    Re: VBA to give the ctrl-F (find) function

    Hey guys! Year 2020 here.
    This is my amateur VBA for an auto-column search:


    Sub Column_Search()
    ' Column Search
    ' Keyboard Shortcut: Ctrl+Shift+F
    '
    ActiveCell.Columns("A:A").EntireColumn.Select
    SendKeys "^f", Wait ' CTRL & F (Find)

    End Sub

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,652

    Re: VBA to give the ctrl-F (find) function

    Did you come here in a De Lorean?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1