+ Reply to Thread
Results 1 to 10 of 10

[SOLVED] Macro to search table and show row info

  1. #1
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    [SOLVED] Macro to search table and show row info

    I'm looking to have a SEARCH and UPDATE form control button that does the following:

    Searches data on table1 for a job number, returns the row data of specific columns...that row data then can be modified and the update button will update the table with the new information.

    data is on worksheet "PROJECTS" / Table1

    Search button takes the unique job number that is entered (manually) into cell E3 on worksheet "DASHBOARD"....searches Table1 column C...then returns the row data from columns S,T,V,W,X,Y,AB,AC,AD into cells F3:N3 on sheet DASHBOARD

    now the trick part...those columns from Table1 consist of a "1" or "0" because i'm using icon sets to show check marks or X marks....so i have check boxes in cells F3:N3...so for example if column S (from table 1) has a value of 1...i need it to check the box on my main sheet....and if I uncheck the box and click UPDATE will will change the table value to 0.

    I've attached my sample...hopefully the example clarifies everything.
    Attached Files Attached Files
    Last edited by adamheon; 07-15-2016 at 10:52 PM.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to search table and show row info

    Is there a reason you're not using a UserForm to perform these actions? It's far easier to manipulate controls that way.

    BSB

  3. #3
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to search table and show row info

    yeah i guess i could use a userform....my thinking was that on this main sheet which has a pivot table showing the status of these items, if i wanted to quickly and easily change the status of a particular job...it would be easier to just type in the job number right on the worksheet and update it ....rather than open a userform and do it that way (which i already have)...for me its the same either way, but i know the person actually using this sheet might get lost with the userforms...so something simple right on the worksheet might be more user friendly?

    however, after writing this out and thinking about it...you're right, i probably should just go with the userform which has only these items on it...especially since most of the code I already have written.

    Thanks for the bringing me back to reality here...

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to search table and show row info

    You could have a worksheet activate event that automatically shows the userform when the dashboard sheet is selected and closes it when another sheet is activated. That way the end user doesn't need to do anything and you could still have the pivot visible. You lose no current functionality but the code is infinitely easier to write and maintain.

    Just my thoughts...

    BSB
    Last edited by BadlySpelledBuoy; 07-11-2016 at 03:40 PM.

  5. #5
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to search table and show row info

    Thats a good idea. how would you go about doing that?

    with my current userform...i have to close it in order to select a new worksheet....so you're saying that you can have a userform that is open and still move around the workbook? or at least select a new worksheet which would close the userform?

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to search table and show row info

    Yes the line below would allow you to open a UserForm and still navigate around and manipulate the workbook.
    Please Login or Register  to view this content.
    BSB

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to search table and show row info

    And this in the Dashboard sheet code module would close the UserForm when you select another sheet if need be.
    Please Login or Register  to view this content.
    Worth noting that if you unload the form rather than just hide it then you'll lose any data you've recorded on it.

    BSB

  8. #8
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to search table and show row info

    So I'm trying to figure out how to use this code

    Please Login or Register  to view this content.
    where exactly do i place it? would i be able to have the userform pop up with you open the work sheet? or do i need a button to open it?

  9. #9
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Macro to search table and show row info

    Place this code in the "worksheet" module. Easiest way to access that is right click the sheet tab at the bottom of Excel and select View Code.
    Please Login or Register  to view this content.
    Then this code in the "workbook" module. In the VB Editor double click on the icon in the "Project window" top right (usually) where is says "ThisWorkbook".
    Please Login or Register  to view this content.
    This will effectively select Sheet1 if it's not already selected when the workbook opens and then open the form, but will also open the form if Sheet1 IS already selected.

    It will also mean once the workbook is open you can select other sheets, but will reopen the form when you go back to Sheet1 if you do decide to have it automatically unload when you select another sheet.

    I hope that makes sense. Shout for help if need be.

    BSB

  10. #10
    Forum Contributor
    Join Date
    04-05-2013
    Location
    CT
    MS-Off Ver
    Excel 2010
    Posts
    360

    Re: Macro to search table and show row info

    sorry i forgot to respond to this. This worked perfectly! Thank you.

+ 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. A macro that search info from a pivot table
    By natatxu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2016, 10:00 AM
  2. Replies: 7
    Last Post: 03-04-2014, 05:53 PM
  3. Possible? Macro that will search and locate a colum of info
    By sdehod in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-17-2013, 01:38 PM
  4. Replies: 10
    Last Post: 08-12-2013, 12:02 PM
  5. Macro to filter content and show not found info
    By Nachol in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2012, 12:49 PM
  6. Search and find info, if correct info found copy into new worksheet
    By JnrParki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2011, 11:36 AM
  7. Excel 2007 : Search, Paste info in Macro for 2007
    By frankhb3 in forum Excel General
    Replies: 1
    Last Post: 12-03-2010, 05:24 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