+ Reply to Thread
Results 1 to 16 of 16

VBA search and retunr results - simple programming

  1. #1
    Registered User
    Join Date
    04-10-2017
    Location
    Southampton
    MS-Off Ver
    Office 2013
    Posts
    4

    VBA search and retunr results - simple programming

    Hi,

    I know this is probably basic programming for some of you: -) but after spending all afternoon watching youtube videos and getting
    the same error message 'For without next' and 'Cannot execute code without break' I finally give up. ;-(
    I have no training or knowledge of excel apart from as a user.

    PLEASE HELP!!!
    ok....ill keep it simple

    on sheet1 I have a search box to enter 'store number; (and a button to link to the macro).
    if a match is found on sheet2 column A (sheet 2 has 5 columns) results should be displayed back on sheet1 D6,E6,F6,G6,H6
    there is more than one entry for the same store on sheet 2 they all need to be displayed on sheet 1 and its not in order.

    this what I've tried so far.....copying a youtube video but it was design to only return one row I need all matches to be returned....
    and it didn't work anyway.

    Please Login or Register  to view this content.
    PS. This spread sheet is for a bank and I can't upload any of the information or onto here :-(
    Last edited by renangv; 04-10-2017 at 02:27 PM.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Hi renangv

    Your post does not comply with Rule 3 of the Forum....
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the [#] button at the top of the post window
    Last edited by sintek; 04-10-2017 at 02:33 PM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: VBA search and retunr results - simple programming

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Please attach a sample workbook with a before & after scenario making sure that your desired solution is shown - mock up the results manually.

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA search and retunr results - simple programming

    from what I can see, you need to add
    Please Login or Register  to view this content.
    with the rest of the dim statements. And add
    Please Login or Register  to view this content.
    right after the End If. Note that if there are multiple results found, the last result will overwrite the preceeding ones.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Perhaps this can start you off. Would be better seeing a sample file.
    Please Login or Register  to view this content.
    Last edited by sintek; 04-10-2017 at 02:51 PM. Reason: Changed x value to 5 Column E

  7. #7
    Registered User
    Join Date
    04-10-2017
    Location
    Southampton
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: VBA search and retunr results - simple programming

    IMG_0478.JPGIMG_0479.JPG
    i've taken some pictures of a sample as i can't upload files from this computer.

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: VBA search and retunr results - simple programming

    You added the pics and not said anything about any of the solutions that have been given. Are the codes not working? If not what is not working?

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Here you go...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 04-11-2017 at 02:59 AM. Reason: Added attachment

  10. #10
    Registered User
    Join Date
    04-10-2017
    Location
    Southampton
    MS-Off Ver
    Office 2013
    Posts
    4

    Smile Re: VBA search and retunr results - simple programming

    Hi Sintek,

    Thank you for your efforts.
    Your spreadsheet it pretty similar to what i need,
    what do i need to add in order for the previous data to clear when you search a new number. *sorry i forgot to mention this.*

    Thanks this is just the initial project i will be adding on more data and more tabs as it progresses but i think this has been really helpful to start me up !

    Quote Originally Posted by sintek View Post
    Here you go...
    Please Login or Register  to view this content.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: VBA search and retunr results - simple programming

    This one should cover that.

    Please Login or Register  to view this content.
    Last edited by bakerman2; 04-11-2017 at 06:01 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Yep, that covers it ....bakerman2 to the rescue lol

  13. #13
    Registered User
    Join Date
    04-10-2017
    Location
    Southampton
    MS-Off Ver
    Office 2013
    Posts
    4

    Re: VBA search and retunr results - simple programming

    Yep . That is perfect :-) thanks Everyone
    Thanks Sintek and Bakerman2

  14. #14
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    Pleasure...Thanks for rep points

  15. #15
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,279

    Re: VBA search and retunr results - simple programming

    @ bakerman2

    Indicator As Boolean
    Of course...Silly me.

  16. #16
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: VBA search and retunr results - simple programming

    @ renangv

    You're welcome and thanks for rep+.

+ 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. Simple search box column and retrive results to search box sheet
    By Tanakaka in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-08-2017, 08:47 AM
  2. Look up 2 coloumn and retunr the multiple values
    By kiranmayi16 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-31-2014, 02:29 PM
  3. Simple search function and results display.
    By dgbradl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2013, 06:33 PM
  4. MATCH and INDEX function retunr the same value
    By albertoro in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-04-2013, 10:44 PM
  5. Simple Spreadsheet programming help
    By theebookzoo in forum Excel General
    Replies: 2
    Last Post: 08-25-2008, 03:27 PM
  6. Programming a simple formula
    By anagaraj1 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-04-2005, 11:05 AM
  7. [SOLVED] Simple Programming Function??
    By Texins Karate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2005, 01:06 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