+ Reply to Thread
Results 1 to 7 of 7

Macro to query data based on a criteria sheet

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    SG
    MS-Off Ver
    Excel 2007
    Posts
    37

    Macro to query data based on a criteria sheet

    Help needed!!

    I've a macro to query data using a criteria sheet (SearchEngine). Data is constantly updated in the Database. However, my query sheet is only able to return search only when the "Name" column (A) is not empty. When an employee has more than 1 row of data, the macro no longer functions as intended.

    E.g. Employee A (A8) can be working in both Singapore and Indonesia. Since it is detail for the same employee, I left the cell A9 empty. When i query Employee A in SearchEngine (D8), it only returns the row A8:H8 and not A9:H9.
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to query data based on a criteria sheet

    Since it is detail for the same employee, I left the cell A9 empty.
    This is the answer to your question. The way you have the data setup, you have to fill in A9.

    I like your file. Its a very neat database.

    I have just got rid of all the select statements that you have there and re-attached your file here. Just have a look.
    Attached Files Attached Files
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    SG
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Macro to query data based on a criteria sheet

    Thank you.

    But is there another way to do it without inserting A9? Cause it is pretty weird for employee database to have repeated names again and again.

    An alternative way that I thought of is to have the repeated names yellow in colour (same colour as the background) so that it is not visible. Are you able to make a macro for it?


    kayyoke

  4. #4
    Registered User
    Join Date
    06-07-2012
    Location
    SG
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Macro to query data based on a criteria sheet

    Eh, sorry..Wrong. Should be white in colour >_< because this query paste the values in the SearchResult and the SearchResult background is white in colour.

  5. #5
    Registered User
    Join Date
    06-07-2012
    Location
    SG
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Macro to query data based on a criteria sheet

    I've found the answer.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to query data based on a criteria sheet

    If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.

  7. #7
    Registered User
    Join Date
    06-07-2012
    Location
    SG
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Macro to query data based on a criteria sheet

    To interested viewers: Here is the extra code for changing the font to white (code no. for white = 2)

    Please Login or Register  to view this content.

+ 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