+ Reply to Thread
Results 1 to 13 of 13

A select query in excel?

  1. #1
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    A select query in excel?

    I have a decent amount of data and each row of data has attributes attributed to a person. The same person can be in the table more than once. What I'd like to do is create some sort of pop up table/form (after they hit a certain button specific to them) in excel for each person showing them all the rows of attributes. It's kind of like running a select query in excel on excel data.

    The person would then be faced with 2 choices approve or disapprove in button form perhaps on the popped up form/table. After clicking one of the buttons, it puts their initials in either a disapprove or approve column. Also, if they hit disapprove, I'd like a pop up message to appear.

    Is this possible in excel?

  2. #2
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: A select query in excel?

    What may suit your needs is on a button click, pop a form that asks for the person's name, then filter the sheet with the attributes for that person.
    They can then click the approve/disapprove button.
    I don't know how many rows/attributes there are, so they may not fit in a form; or the person may need to scroll up/down or left/right to see all of their attributes.

    An alternative is to show the attributes on a second sheet.
    But yes this would be doable in Excel

  3. #3
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    I think what I'll do is the advanced filter to bring the data over. My question is, can I have the person type there name in the Criteria Range and have the filter automatically run to bring over the data? That way they don't have to do anything. How do I do that?

  4. #4
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: A select query in excel?

    When you say "... the advanced filter to bring the data over." Are you filtering or copying data? If filtering, there is nothing to bring over, you're on the attribute spreadsheet.
    You can have the person click on a button to kick off the filtering. As far as I know there is no event trigger when you enter data into a cell, except in a form.

  5. #5
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    hectop - Thank you for the guidance.

    So after your last comment, what I think I'll do is have 2 worksheets. On sheet 1, they enter their name into a certain cell, which will be my "Criteria Range" for the advanced filter. They will then hit a button to run the advanced filter, which will bring over the data from the second worksheet.

    I'm not too familiar with VB; is there anything I should know (helpful tips) before I try to figure this out?

    Thanks again!

  6. #6
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: A select query in excel?

    There was a similar question a little while ago that I answered. The attached worksheet will show how it can be done.
    One thing to notice here is that there is a Create Emp ID List button. This would (re-)create a named range of employees so that you could you a drop down list to select the name rather than have the name typed in. This would ensure that there are no typos or inconsistencies in how the criteria range is populated.

    Have fun with it.
    PopEmpDtls.xlsm

  7. #7
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    Brilliant! Thanks!!!

  8. #8
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    So I ran into a problem. I built my spreadsheet and thought it was good to go, but...

    So I have 2 sheets named "review sheet" and "data". The data sheet has my raw data in a table. I created a pivot table off that data to only show the person's name once (remember there are multiple rows for a person with different attributes in each row). I used that pivot table to create a drop down box in the review sheet. I hit my buttons and everything is fine. However, when I right click and refresh the pivot table, I will get an Runtime error 1004 when I hit my button that runs my advanced filter macro that says "Advancedfilter method of Range Class failed". I don't really understand VB, but when i debug it shows my macro with the 2 lines above "End Sub" in yellow with a yellow arrow pointing to the latter of the 2 lines.

    Please Login or Register  to view this content.
    When I refreshed the pivot table, none of the data changes the ranges to invalidate the range cells in the macro.

    Any thoughts?

    I tried to look at your spreadsheet as I thought the "Create Emp Id" button would work. But when I looked at the code, I had no idea what to do. So I searched online and found the pivot table idea, which got me to the same result...but then I got that error.

    By the way, I can't upload the spreadsheet because there is sensitive data in it.

    Thanks!
    Last edited by alansidman; 10-26-2013 at 06:47 PM. Reason: Code tags added

  9. #9
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: A select query in excel?

    The button Create Emp ID List executes the subroutine DedupEEs which creates a list of unique employee ID numbers in column J
    You need to modify it:
    - Worksheets("Raw").Cells(nRRow, 1).Value. Change the 1 to the column that has your names (that you use for criteria range selection)
    - nRngCol = column that you want your unique list written to
    - sRng = "=Raw!R2C10:R" & Trim(Str(nSRow)) & "C10"
    - you need to change R2C10 to the relative row/column where the unique list starts
    - the last C10 is changed to the relative column number where the unique list is located. This needs to be the same as 1st C10 in this line

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,945

    Re: A select query in excel?

    Isotopes, Welcome to the forum

    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.

    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



    (I have added them to your posting for you this time. Please read our rules and follow them in the future)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  11. #11
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    Hectop - Thank you so much! I was able to adjust the code with your instructions and can now use my spreadsheet with no errors! I appreciate your Excel/VB expertise as it has saved me hours of headache and I also learned a few things along the way. THANK YOU!!!

    Alan - Sorry about the code rule. It won't happen again.

  12. #12
    Forum Contributor
    Join Date
    09-30-2013
    Location
    Toronto, ON
    MS-Off Ver
    Excel 2007
    Posts
    229

    Re: A select query in excel?

    Your welcome. Please click on the Add Reputation button.
    Thanks

  13. #13
    Registered User
    Join Date
    10-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: A select query in excel?

    Yep - I added to your rep yesterday. I guess this thread is solved.

+ 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. [SOLVED] How to select ALL within query
    By tigerbalm in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-11-2013, 11:09 AM
  2. [SOLVED] SQL select query problem in excel vba maco code.
    By ravikumar00008 in forum Excel General
    Replies: 0
    Last Post: 07-23-2012, 06:02 AM
  3. [SOLVED] select database file path location for excel query
    By GerryE in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-11-2006, 08:30 PM
  4. [SOLVED] Excel MS Query multiple select statements
    By Revenger in forum Excel General
    Replies: 3
    Last Post: 05-12-2006, 07:40 AM
  5. [SOLVED] MS Query-ability to edit select query
    By Robert in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-14-2005, 09:06 AM

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