+ Reply to Thread
Results 1 to 5 of 5

VBA to combine referenced rows into one sheet

  1. #1
    Registered User
    Join Date
    10-14-2023
    Location
    Florida, USA
    MS-Off Ver
    2309
    Posts
    2

    VBA to combine referenced rows into one sheet

    Hey there, I am new to this forum and I've got a very specific need that I cannot seem to solve using a search engine or ChatGPT. I am hoping someone here is able to help me out. To provide some context, I work for a child welfare agency and we have to keep track of all the children in care and when they were last seen in their current homes. Every day I need to get responses from the case workers on their efforts. I carry over these responses from one day to the next and either keep the ones that still apply or delete the ones that need new information provided. The easiest way I have found to do this is to create a "combined" sheet which references all of the rows from the other sheets. Then I use a vlookup function to pull yesterday's responses into today's report if the children still appear in the report.

    What I have been doing is clicking cell A2 in the combined sheet, typing "=", then selecting all of the rows that contain data in sheet "CAM". Then on the combined sheet I go down to the first blank row and do the same thing for the next worksheet and so on until the combined sheet has referenced all of the rows from all the other sheets (minus the header row obviously). The rows have to reference the original because I need it to update every time someone goes in the worksheet and provides a response to each child on the list.

    This process really doesn't take me that long to manually do, but I do it every day and it's just annoying knowing that there has to be a way to include this in my macro. I just cannot figure out how to successfully do it. I have attached a version of the spreadsheet with all of the confidential information replaced. I was going to provide an example sheet to show what the finished product looks like, but it made the file size too big to upload.
    Attached Files Attached Files

  2. #2
    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,888

    Re: VBA to combine referenced rows into one sheet

    If you have power query available then you can bring your tables into PQ editor and append each to the other. Once you have done this, any updates will be reflected in the combined sheet when you select Refresh All

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.
    Attached Files Attached Files
    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

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hello, try this !


    According to the attachment a starter VBA demonstration to paste only to the Combined worksheet module :

    PHP Code: 
    Sub Demo1()
            
    UsedRange.Offset(1).ClearContents
            R
    & = 2
        
    For S& = Index 1 To Worksheets.Count
            T
    & = Worksheets(S).[A1].CurrentRegion.Rows.Count 1
         
    If T Then
            Rows
    (R).Resize(T16).Formula "='" Worksheets(S).Name "'!A2"
            
    T
         End 
    If
        
    Next
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 10-15-2023 at 03:49 AM. Reason: simplification ...

  4. #4
    Registered User
    Join Date
    10-14-2023
    Location
    Florida, USA
    MS-Off Ver
    2309
    Posts
    2

    Re: Hello, try this !

    You are amazing! Thank you so much!

    And to alansidman, yes, I want to learn Power Query for sure. It's just hard when I'm so busy all of the time. Plus all the spreadsheets I have to work off of start out as CSV files and need a lot of adjusting prior to moving any data between different worksheets.

  5. #5
    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,888

    Re: VBA to combine referenced rows into one sheet

    csv files are easy to work with in PQ. Suggest you pick up this book https://www.amazon.com/Master-Your-D...s=books&sr=1-1.

+ 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] Combine Values from Duplicate References
    By hzrdc2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-19-2017, 12:58 PM
  2. How to combine many rows into one on a separate sheet
    By katieshields in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2017, 08:49 AM
  3. Excel VBA combine common rows based of two columns place into another sheet
    By jurjevics in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2016, 02:17 PM
  4. [SOLVED] Combine Selected Columns & Rows Informations from Multiple Excel Sheets to one sheet
    By akherief in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2016, 07:44 AM
  5. Replies: 2
    Last Post: 06-11-2014, 11:14 AM
  6. Combine Duplicate Rows and Combine Data in Rows
    By cherylmcgk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 12:04 PM
  7. How to create Read/Write VBA Userform that references variable cells/rows in a sheet?
    By Sivart9876 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2012, 10:58 AM

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