Need help consolidating data from multiple sheets into one sheet

gkisystems

Board Regular
Joined
Apr 20, 2012
Messages
76
I have a macro that pulls in a tab called "Registration Form" from multiple other files and dumps it into my working file. I also have a "Control Panel" and "Master" tab in my working file. As a result, the tab names in my worksheet are as follows:

Control Panel
Master
Registration Form
Registration Form (2)
Registration Form (3)
...
and so on.

I need all the data in the registration forms to be copied and pasted into the Master tab. On each registration form, the amount of data varies. The largest data range would be A1:F16 with the smallest being A1:F2 on each registration form. The total number of "Registration Form" tabs will also vary, so I am unable to reference the specific tab names.

The following macro does what I need it to except it is static and I need help making it dynamic. Specifically, I need help in telling the macro to go find the "Registration Form" tabs, regardless of however many of them I have instead of looking at specific tab names. Any help is appreciated!


Code:
Sub LoadMaster()
'This macro goes to each Registration Form and copies data in columns A-F.
'The data gets appended to the bottom of the data on the Master tab.


    Sheets("Registration Form").Select
    Application.Goto Reference:="R1C1"
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Sheets("Master").Select
    Application.Goto Reference:="R1C1"
    ActiveSheet.Paste
    
    Sheets("Registration Form (2)").Select
    Application.Goto Reference:="R1C1"
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Master").Select
    Application.Goto Reference:="R1C1"
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select
    ActiveSheet.Paste
    
    Sheets("Registration Form (3)").Select
    Application.Goto Reference:="R1C1"
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Master").Select
    Application.Goto Reference:="R1C1"
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select
    ActiveSheet.Paste

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Would this work for you...


Code:
Sub LoadMaster()
'This macro goes to each Registration Form and copies data in columns A-F.
'The data gets appended to the bottom of the data on the Master tab.

    Dim wsct As Single
    Dim i As Single
    wsct = Worksheets.Count
    
    For i = 2 To wsct
    
        Sheets("Registration Form").Select
        Application.Goto Reference:="R1C1"
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Selection.Copy
        Sheets("Master").Select
        Application.Goto Reference:="R1C1"
        ActiveSheet.Paste
    
        Sheets("Registration Form (" & i & ")").Select
        Application.Goto Reference:="R1C1"
        Range(Selection, Selection.End(xlDown)).Select
        Range(Selection, Selection.End(xlToRight)).Select
        Application.CutCopyMode = False
        Selection.Copy
        Sheets("Master").Select
        Application.Goto Reference:="R1C1"
        Selection.End(xlDown).Select
        Selection.Offset(1, 0).Select
        ActiveSheet.Paste
        
    Next
    
    End Sub
 
Upvote 0
I see now that you have another worksheet in there, you may have to change

Code:
For i = 2 To wsct

to

Code:
 For i = 2 To wsct-2

Sorry about that.
 
Upvote 0

Forum statistics

Threads
1,215,317
Messages
6,124,232
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top