+ Reply to Thread
Results 1 to 17 of 17

Search multiple sheets, return entire rows under each sheet name

  1. #1
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Search multiple sheets, return entire rows under each sheet name

    Hi clever peeps

    MANY years ago I was able to write basic VBA, create forms etc, but recent attempts over some largely unproductive hours pretty much tells me I have lost that ability - too long between drinks - so I'm asking for your help.

    I have a workbook that has a sheet for each active project (around 10-15 projects at any one time). On each project sheet, there are running lists of tasks with each task assigned to one of our workers.

    I want to be able to create a separate list of all tasks assigned to a selected worker (on the 'Your Tasks' sheet). The list is to include the whole row of data for the task.

    So, I wish to:
    1. Nominate the search value - worker's initials, currently entered via a simple data validation list (e.g. "AB")
    2. Check all project sheets for this value, searching in only Column A of each sheet
    3. With each successful hit, I'd like two things to occur in the Your Tasks sheet:
    a. Insert the name of the sheet (project) in a new row (only once no mater how many hits on that sheet)
    b. Beneath the sheet name, return the entire row for each search hit for that project

    The ideal result would show the search term (worker's initials) in the data validation cell followed by each project name and the tasks within that project that are assigned to that worker
    Please see the attached data sample (simplified and confidentials removed)

    Any help welcomed.
    THANKS IN ADVANCE
    Attached Files Attached Files

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    Hi Black Duck

    Welcome to the forum...If I understand correctly then this is one option...
    Only "Current tasks" - Right

    This code in sheets("Your Task").Module
    Please Login or Register  to view this content.
    And this in a stand alone Module...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    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 [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    Hi sintek

    Thank you for your time and awesomeness!

    I notice the use of 'Project *' for the sheet names per my sample data, but this was meant to signify that each project has a different name, so unfortunately it won't work at this stage. I do have VBA code that runs through the sheets and creates a hyperlinked index for me, and I think I might be able to use this with your code.

    I'll have a play and try to make it happen, but if you are willing to make adjustments based on this feedback, I'd be very grateful.

    Thanks heaps

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    I notice the use of 'Project *' for the sheet names per my sample data, but this was meant to signify that each project has a different name, so unfortunately it won't work at this stage
    Firstly, have you tested it on your uploaded sample before making the above statement...
    Secondly, No it won't work if your actual file setup is different to your sample upload...as the code is written for your initial requirement...
    To rectify this you need to Upload a sample file depicting actual sheet names...
    In future, also, to ensure accuracy and no time wasted on code, please upload actual file setup sample and explain in detail what your requirement is...

    OR

    If the only sheets that need to be excluded are INDEX and Your Tasks then

    Replace this line...
    Please Login or Register  to view this content.
    With ...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 01-09-2020 at 03:11 AM.

  5. #5
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    My apologies sintek
    Just to clarify, YES your code WORKS for the sample. Unfortunately not on the working version. I am sorry for sounding ungrateful - the reason I have not supplied a copy of the working file or used actual project names is to avoid sharing confidential information. I am not at liberty to divulge client identities, projects, and/or subcontractor names.
    Thanks for hanging in there with me

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    Unfortunately not on the working version
    Is the SET-UP at least the same as your sample...Have you changed the line of code that I suggested in Post 4

    Can you elaborate...What is it not doing...Can only help you if you are prepared to be more transparent...

  7. #7
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    Hi again sintek
    I did substitute the line of code and the code ran. It updated nicely when I changed the search term and rebuilt the list of tasks. However, although the code was running, it was not returning the line with the search term. It returned rows where the cell in Column A was blank. I am now incurring a run-time error on line 27
    .Range("A4").Resize(cnt, 3) = Temp
    I'm not sure what info you require but you've got it so close! Please let me know what further info would help.
    Thanks again
    Attached Images Attached Images

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    My apologies sintek
    Just to clarify, YES your code WORKS for the sample. Unfortunately not on the working version
    As per post 6 which was not answered...
    Is the SET-UP at least the same as your sample
    Can only help you if you are prepared to be more transparent...
    I am not at liberty to divulge client identities, projects, and/or subcontractor names.
    Could go around in circles forever...Your actual file is not then setup as per your sample so unfortunately if you aren't prepared to come to the party, so to speak, and upload a sample file depicting your actual setup desensitizing the information - then I, or no one else for that matter, will be able to help...

    Good luck...

  9. #9
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    You sound angry. I'm honestly trying not to hinder progress. The truth is, I actually thought I had uploaded a good desensitised sample of the file. I'll try again and this time I will be much more cognisant of what I am deleting and changing.
    For the record, I am genuinely very grateful for your help.

  10. #10
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    Hi sintek
    Sample file #2.
    Attached Files Attached Files

  11. #11
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    Hi Black Duck

    Your post #1 refers...
    I want to be able to create a separate list of all tasks assigned to a selected worker
    My response in Post #2 refers
    Only "Current tasks" - Right
    Hence this snippet within the code...
    Please Login or Register  to view this content.
    Your sample 2 upload has this code changed to...
    Please Login or Register  to view this content.
    May I ask why...

    Changing that snippet back to original solves...
    When I select WHO from cell [A2] in "Your tasks" sheet it lists all the "CURRENT TASKS" for that selected WHO...

    I think the best option is for you to upload a sample file once again with the expected result required displayed...This will ensure accuracy...
    Last edited by Sintek; 01-17-2020 at 04:22 AM.

  12. #12
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    Ahhh yes. I have been playing a little to try and understand how your code works; making temporary hard-code changes, running it and learning from the outcome. This is one I hadn't yet changed back to your code.
    I'll add a sample expected result as you suggest.

  13. #13
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    ...additionally, 'all tasks' includes ANY row of data on each sheet that has the WHO in Column A. This includes tasks under Ordering (which tells the team what needs to be delivered to site soon), and Current Tasks (which let's us all know what stage the build is at). There will not be a WHO under Notifications. I figured that once you got the code happening for Current Tasks, I'd be able to add other areas of the sheet to the search.

  14. #14
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    Sample data #2.1
    Attached Files Attached Files

  15. #15
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    Black Duck Black Duck Black Duck...

    Just trying to help so that in future you know exactly what you need to do to expedite assistance...So the next time round, no time is wasted on unnecessary code...

    tasks within that project that are assigned to that worker
    ...additionally, 'all tasks' includes ANY row of data on each sheet that has the WHO in Column A
    Well...If you had started with this then this thread could have been solved days ago...
    My response in Post #2 refers
    Only "Current tasks" - Right
    Next...Your expected results is incorrect...
    WFC has more than just one entry...It has 3
    Am Warehouse is actually Am WH
    SWaRA includes entries for AB/JT as well ...You did not mention that shared employee tasks should also be extracted...

    Lastly which should actually be the most important...Get rid of your merged cells...They just create havoc with VBA...

    I have attached a file housing the new code...with the correct results extracted...
    Have only extracted columns A to C...
    Attached Files Attached Files
    Last edited by Sintek; 01-20-2020 at 03:54 AM.

  16. #16
    Registered User
    Join Date
    01-06-2020
    Location
    Adelaide, South Australia
    MS-Off Ver
    Excel Business 2016
    Posts
    10

    Re: Search multiple sheets, return entire rows under each sheet name

    THANK YOU sintek
    ...on several levels
    • for your skill
    • for your patience!
    • for helping me do this better next time!

    Your code is fab!

    "Black Duck Black Duck Black Duck..." made me laugh. Clearly I have tested your patience... if I could add another star to your Reputation, I would do so, as I think you deserve it.

    MANY THANKS AGAIN

  17. #17
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,957

    Re: Search multiple sheets, return entire rows under each sheet name

    .............................................
    Thanks.gif
    Remember-Mark thread as solved
    Last edited by Sintek; 01-21-2020 at 02:14 AM.

+ 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. Search the value in multiple sheets and display the entire row of matched value in list bo
    By haridevadiga in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-26-2015, 08:08 AM
  2. Replies: 6
    Last Post: 01-13-2015, 12:35 PM
  3. Return entire rows from multiple sheets into one table
    By h_685 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-08-2014, 04:33 PM
  4. [SOLVED] I need to search for a word on multiple sheets and copy the entire row to a new sheet
    By jkm750 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2013, 12:13 AM
  5. Search value in multiple sheets and return sheet name(s)
    By evolv12 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2013, 02:11 PM
  6. [SOLVED] Search multiple sheets for criteria and paste all matched rows in new sheet
    By BertLady56 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2012, 01:09 PM
  7. Search for Multiple String Values on Multiple Sheets and Copy Rows to New Sheet
    By rrtikker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-15-2012, 12:21 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