+ Reply to Thread
Results 1 to 8 of 8

Pulling data from a sheet(s) by entering sheet name(s)

  1. #1
    Registered User
    Join Date
    04-12-2023
    Location
    United States
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    22

    Pulling data from a sheet(s) by entering sheet name(s)

    Hello Gurus,

    This might be a big one...

    I need to be able to enter a SHEET NAME(s) in a cell(s) and it pulls data (by column) from a sheet corresponding with that name. I would need to be able to pull data from MULTIPLE sheets and have the data listed on one sheet.

    Please see attached worksheet.

    Thank you kindly!
    Coni
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2024
    Posts
    996

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    Hi there,

    The following code works by checking all entries in column 'A' on Sheet1. When a sheet is found matching the name, the data from row 2 is copies onto Sheet1 in column C at the bottom of any existing data.
    Data is copies in the order the Sheets are listed in column 'A'.
    Sheet names in column 'A' must be exact as the sheet names (case sensitive).

    Let us know if that works for you.


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by ORoos; 06-29-2023 at 02:16 AM. Reason: Added commenting in code
    If your Question is answered; please mark it SOLVED. If you are happy with a member's solution, say 'Thanks' and click the 'Star' to Add Reputation.

  3. #3
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    VB is probably the most effective way to do this...

    You could do formulas but this requires presetting the data with a fixed number of sheets able to be pulled in and a max row limit...

    This is limited to 3 sheets and 3 columns... you would need to change the reference that is RED below to add additional columns and add an entire BLOCK to add more sheet availability...each time you add a sheet you have to subtract the previous block... I limited this to 2000 rows from the sheets but you can add more and drag these 3 formulas down to get beyond the max (Which would be 6k right now provided each sheet had that many...



    C4 =
    Please Login or Register  to view this content.
    D4 =
    Please Login or Register  to view this content.

    E4 =
    Please Login or Register  to view this content.
    -If you think you are done, Start over - ELeGault

  4. #4
    Registered User
    Join Date
    04-12-2023
    Location
    United States
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    22

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    This is great! However I am having some trouble 'tuning' it to my application.

    I cannot get a "Run Macro" button like in your attachment.
    The data from other sheets is not pasted in order, instead its pasted over the previous inputs
    Last edited by ConiferousCanada; 06-29-2023 at 04:13 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2024
    Posts
    996

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    When running the macro, the data from the sheets is listed in order as they are in column 'A'.
    In your original sample file you had 3 sheets, getting an output list of 9 items.
    Running the macro from your original sample file, I get all 9 items.

    In my sample file you should get only the 6 item values of 'Sheet2' & 'Elements'; Wheel, Clock, Nut, Door, Handle, Window listed from cell 'C4' down.
    Values from 'Sheet3' (does not exist) and 'sheet4' (case from sheet name does not match) are ignored. I have done this to illustrate how it works.


    For a button, insert any shape or picture. Right-click on it and select 'Assign Macro'. Select the macro you want to run...

    Instead of a 'Run Macro' button, you can run the macro from the Developer tab > Macros

  6. #6
    Registered User
    Join Date
    04-12-2023
    Location
    United States
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    22

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    Thank you. I will figure out the button.

    How can I code it so there is NO limit for the data pulled from a sheet - sometimes its 1 line of data, others it can be 100!

    Furthermore, if I am pulling data from multiple sheets, each ranging in many lines of data, how can I ensure that all the data is listed one after another without copying over data from other cells?

    Thank you!
    CONI

  7. #7
    Registered User
    Join Date
    04-12-2023
    Location
    United States
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    22

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    Quote Originally Posted by ELeGault View Post
    VB is probably the most effective way to do this...

    You could do formulas but this requires presetting the data with a fixed number of sheets able to be pulled in and a max row limit...

    This is limited to 3 sheets and 3 columns... you would need to change the reference that is RED below to add additional columns and add an entire BLOCK to add more sheet availability...each time you add a sheet you have to subtract the previous block... I limited this to 2000 rows from the sheets but you can add more and drag these 3 formulas down to get beyond the max (Which would be 6k right now provided each sheet had that many...



    C4 =
    Please Login or Register  to view this content.
    D4 =
    Please Login or Register  to view this content.

    E4 =
    Please Login or Register  to view this content.

    Thanks ELeGaut, is this code you provided to be put into VBA?

  8. #8
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2024
    Posts
    996

    Re: Pulling data from a sheet(s) by entering sheet name(s)

    Hi Coni,

    What exactly is not working for you?
    The code does exactly what you asked for.

    Please refer to the attached file.

    Any text starting from cell 'A1' on each sheet will be copied, irrespective of how many rows or columns (up to the first empty row/column).
    I have added a few different samples to the attached file. Just press the button and see the result.
    You will get all 20 entries from the 5 sheets.

    If your actual data is different from the original sample file, may upload a file (sanitized without any confidential info of course) to test on.
    Attached Images Attached Images
    Attached Files Attached Files

+ 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] Google Sheet Issue: pulling data from one sheet to another sheet or workbook
    By Mofasol in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 05-28-2023, 12:35 AM
  2. Replies: 1
    Last Post: 05-27-2023, 12:15 PM
  3. Replies: 0
    Last Post: 05-27-2023, 12:01 PM
  4. [SOLVED] Pulling Data from 1 sheet or sheets to a master sheet(Profile sheet)
    By Majord89 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-09-2021, 09:35 AM
  5. Replies: 5
    Last Post: 02-09-2014, 08:29 PM
  6. Replies: 10
    Last Post: 08-14-2013, 03:32 PM
  7. Taking data from sheet 3 and auto entering it useing a keyword to sheet 1
    By mark petrak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2008, 10:32 PM

Tags for this Thread

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