Combining 2 sheets of data with one Macro

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have to update two raw files each day and then combine them

One file has 1600 or so rows and the other has 250. Each day this increases. I usually copy and paste the raw files into the same workbook each day and then combine them. I was wondering is there some code that could combine them for me without any gaps in between?

Tab 1 is called SFC and tab 2 is called RPG.

I need to select all the data on each and then combine them on to a tab called Combo.

Thank you
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Sub Combine()
Dim Lastrow As Long
Dim Lastrow1 As Long
Dim Lastrow2 As Long
Application.ScreenUpdating = False

Sheets("SFC").Select
Lastrow1 = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
Rows("2:" & Lastrow1).Copy
Sheets("Combo").Select
Lastrow = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
Rows(Lastrow).Select
Selection.Insert Shift:=xlDown
Sheets("RPG").Select
Lastrow2 = ActiveSheet.UsedRange.Row - 1 + ActiveSheet.UsedRange.Rows.Count
Rows("2:" & Lastrow2).Copy
Sheets("Combo").Select
Lastrow = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count
Rows(Lastrow).Select
Selection.Insert Shift:=xlDown
Application.ScreenUpdating = True
End Sub



The merging will happen eachtime you run this macro
 
Upvote 0
Thanks, that copies and pastes to one sheet but has a gap of 1489 rows between the 2 sets of data?
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,838
Members
449,471
Latest member
lachbee

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