+ Reply to Thread
Results 1 to 45 of 45

Macro for Find Button command

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Macro for Find Button command

    Hello
    I am looking for a code for the "FIND" button in the worksheet vba code that when I click the button will search the particular item that I am looking for. For example, I am looking for "HOURS" that is in Sheet2 "when I click the button then it will find the it.

    See attachment of the sample file.
    Attached Files Attached Files

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Record a macro with and press Crlf + F record and you have the code.
    Link this macro to a button and you're done.
    Just edit the recorded macro, add an input box to enter the text or whatever to search for.
    If you record it and use find all it will search for ALL occurences.

    Hope this helps a little you can always attach the recorded macro and we'll see who can help you further.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Im confuse :0(

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    What confuses you?
    Recording a macro?
    Every action you do in Excel can be recorded as a macro, you give it a name and editing the 'created VBA code' it will make it suitable form more that just that search.
    Have you ever worked with VBA? Or are ju just pasting some code in your file without the basics of knowing what VBA does?

  5. #5
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi Keebellah
    I don’t work vba and no knowledge of it. Maybe just a very little.
    Thanks

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    This is the code you need
    Please Login or Register  to view this content.
    I placed it in the file for you.
    Please, when you attach a file that is macro embedded (xlsm) the assumption we all make is the the person knows what he's asking.
    There is no harm in telling us that your VBA knowledge is minimal or lacking but don't give wrong assumptions.

    Don't we worry we all started from scratch and recording macros
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    I will next time.
    Wow! I liked it a lot :o)
    I am learning little by little but it is really complicated especially my English is not very well.

    Can you do me another favor....
    What if I just want to search just specific sheet like Sheet2 and does not include Sheet1.

    Thanks :o)

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Please Login or Register  to view this content.
    Modify the code I gave you like this or copy it

    Wha's your native language? Spanish?

  9. #9
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    Wow! you're a genius. I want to be like you :o) I start studying and learn the basic vba but like I said, its way too complicated for me. But with your help and the others here in the Forum, I am achieving something.

    I am Asian and I do have a lot of great Spanish friend. Yo hablo espanol poquito :o)

    Thanks again K-


    Thanks again

  10. #10
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    K-
    I am trying to add Sheet3.
    should it be like this?

    Set ws = Worksheets("Sheet2,Sheet3")

    Thanks.

  11. #11
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Nope, then you use the loop again and test for the sheet name.
    VBA is simple, it's straightforward but it takes practice and wat you need most is time, (a lot of it) and patience to look for solutions.
    Google is an ideal tool to look for examples, Google VBA EXCEL and the question and you'll get many hits
    About the Spanish was just curiosity
    Good luck, I've been doing this for over 25 years (maybe enve longer)

  12. #12
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K
    ;o) loop? I tried most of i can think of. None of my try out did not work. Sorry...

    Set ws = Worksheets("Sheet2”,”Sheet3”)

    This did not work either.

    I actually pretty much youtube on the basic vba lessons.

    Thanks

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Please Login or Register  to view this content.
    Try reading the code as you would a book that is all it it is.
    the For each Ws in ...

    you read for each worksheet that I have in my workbook
    the next line (modified for your sheet2 and 3) you ask the question if the worksheet is named sheet2 or if it is named sheet3 then
    check in all cell's values if part of the text you're searching matches what you have entered and ignore the case sensitivity
    if a match is found, select that cell and stop

    That is what the code does and that is how all code works

    So what you do is write down the actions YOU would do to achieve something with if this then that else something else and after you have written it down you write it as vba code respecting the syntax.
    You tube isn't too bad but look up tutorials that explain code and have sample workbooks and play around.
    There are many sites, Ozgrid, Peltier, Walkenbach, Ron de Bruin and of course a forum like Excel Help where you can look at what others asked and did

    HAppy coding

  14. #14
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    Wow! It will be a long journey for me :o)

    Ok, i will check the site yoo provided.

    Thanks you again.

  15. #15
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Good morning K-
    I have encounter a little issue in the workbook. Most of the worksheets has same item for example "apple" but has a different amount. When I click the button and it only search one item in the workbook and if I click again it just stay there. I need a message that will say "find next" then when it locates the last one then it will say "that's it folk :o)".

    Thank you my friend

    This code is for finding the entire workbook:

    Please Login or Register  to view this content.

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    You never mentioned duplicates, well the code nees editing and a way to ask the user which one, where is the ammount, to the right or to the left of the found cell?

  17. #17
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Sorry, did not think of it until i play around w the workbook.

    I actually just want to go “find next” because when it located it highlight the cell then If its not the one then i will just keep clicking the button until i see what i needed.


    Thanks

  18. #18
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    The duplicates “apple” will be in a different column. It is not always in same row or column.

    Thanks

  19. #19
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    I attached the sample workbook and each sheet has an "apple".

    Thanks :o)
    Attached Files Attached Files

  20. #20
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    You still have not answered wher the cell with the value is. Next (to the right) of in this cae apple or to the left or somewhere else?
    You will understand why I want to know this when I get it working.

  21. #21
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Aaaah.... i don’t know if i understand your question but i think right?
    Did u see the workbook i attached?

    Thanks

  22. #22
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    K-
    Here is the attachment just in case you did not get it before.

    Thanks.
    Attached Files Attached Files

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    I gat the attachment all right but the only things I see is the text apple in more than one sheet but you also mentioned values so I think: what values where are they on the sheet or only the word apple or peach or whatever ?

  24. #24
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Just the word “apple”, or “peach” or jist whatever i need to look for. The apple or whatever that it can be enter several time in Sheet1 and some located in other sheet.

    When u say value what is that mean?

  25. #25
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Forget all my questions.
    Another way
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    I like it :o)))
    but there is more. It only searching for "Apple" what about if I search for "Orange" or "hours", "house", etc.

    Thanks.

  27. #27
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Do you know how to type?
    A stupid question gets a stupid answer. and if your question is serious then I think I give up on you
    Think it over

  28. #28
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Seriously, when i type “apple” in the box then it searches all the apples in the workbook. So then, i try to search “hours” or the “banana” from the workbook but it is not doing anything. Try it from ur workbook you sent it to me and you will see what i meant.

    Thanks

  29. #29
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Well I gues you should try your typing skils.
    Attached Images Attached Images

  30. #30
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    WELL? Did you try and test?

  31. #31
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    I don’t know why it does not work on my part.

    What version u have?

  32. #32
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    I dont know why it doesn’t work in my part.
    I am doing exactly what u have in the images

  33. #33
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    The same one if you are using the last file

    Always start on sheet 1
    Attached Files Attached Files

  34. #34
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi,

    Can you please resend me your workbook and hopefully will work.

    Thanks.

  35. #35
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    How about reading the post? Its'attached in #33
    I'm off to bed now.

  36. #36
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    For some reason it is not working in my part. Maybe you have a latest version.

    Thank you.

  37. #37
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Ok Good night :o)

  38. #38
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    YOU ALSO HAVE THE LATEST VERSION,
    I'll attach it once more
    Attached Files Attached Files

  39. #39
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Good morning :o)
    I think I figured it out and it took a while. When I was in Sheet1 where the button is, I was searching the "banana" and it was not searching it because the workbook only searching Sheet2 and Sheet3. Can you make it to search for the entire workbook?

    Also, I like the way you have the Box where the item is in Sheet1 or Sheet2 or Sheet3 and where the cell is. Can you add the item and value?

    Something like this: Let Say "apple"
    o Sheet1 $A$3 Apple $2
    o Sheet2 $C$6 Apple $200
    o Sheet3 $D$1 Apple Uknown

    I Attached the file.

    Thank you
    Attached Files Attached Files

  40. #40
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    That is what I was asking you all the time where is the value? YOU WOKE UP !!!!
    And why Apple, YOU KNOW IT's APPLE since YOU search for Apple.

  41. #41
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Yes i just learned what is value :o)
    Since my english is not good and it actually takes a while before i will understand.

    Apple is to say as an example... i guess

    Thanks

  42. #42
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    Now is time to start trying it for yourself and learn
    You’re asking things you did not want or did not understand well start understanding and learning

  43. #43
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi
    Ok..
    Will you be able to fix it for me?

    Thanks.

  44. #44
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro for Find Button command

    This is my last one for you.
    Attached Files Attached Files

  45. #45
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,719

    Re: Macro for Find Button command

    Hi K-
    This is way perfect!
    Well, I want to say Thank you for all.

    Have a nice day :o)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-02-2016, 10:27 PM
  2. Inserting Row Macro using Command Button (ActiveX) relative to Button
    By mebailey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2016, 09:17 PM
  3. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  4. [SOLVED] Find Next Record Command Button
    By aearce2000 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-30-2014, 07:41 AM
  5. VBA | Find Today's Date by Command Button
    By maintguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2012, 01:04 PM
  6. FIND - command button
    By DSJ in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-02-2007, 06:58 PM
  7. [SOLVED] Find Command Button
    By NeedMorHP in forum Excel General
    Replies: 1
    Last Post: 06-06-2005, 03:05 PM

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