Coping multiple sheets from another workbook to 1 worksheet in current workbook

mssbass

Active Member
Joined
Nov 14, 2002
Messages
253
Platform
  1. Windows
Code below is working but once it pastes the first worksheet data, it deletes it then pastes the 2nd worksheets data. I need it to paste the 2nd worksheets data below the first.

Sub ImportECINS()

Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long

StrDate1 = Format(Date - 1, "yyyy")
StrDate2 = Format(Date - 1, "yyyy") & "-" & Format(Date - 1, "mm") & "-" & Format(Date - 1, "dd")

Application.DisplayAlerts = False
Workbooks.Open ("\\abc\Shares\Files\Data\ECINS\" & StrDate1 & "\" & "ECINS_" & StrDate2 & ".xlsx")


Set wsDest = Workbooks("Fax Daily Closed Report Template.xlsm").Worksheets("ECIN Closed Report")
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "F").End(xlUp).Offset(1).Row

wsDest.Range("D2:DV" & lDestLastRow).ClearContents

For Each wsCopy In Workbooks("ECINS_" & StrDate2 & ".xlsx").Worksheets
wsCopy.Range("A2:DS" & Cells(Rows.Count, 1).End(xlUp).Row).Copy _
wsDest.Range("D2")
Next wsCopy

End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi mssbass,

Untested but see how replacing this line...

VBA Code:
wsCopy.Range("A2:DS" & Cells(Rows.Count, 1).End(xlUp).Row).Copy _
wsDest.Range("D2")

...with this goes:

VBA Code:
wsCopy.Range("A2:DS" & wsCopy.Cells(Rows.Count, 1).End(xlUp).Row).Copy Destination:=wsDest.Range("D" & wsDest.Cells(wsDest.Rows.Count, "D").End(xlUp).Offset(1).Row)

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,215,694
Messages
6,126,253
Members
449,305
Latest member
Dalyb2

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