I have a workbook that has four worksheets with data in each. I need to open another workbook and copy from there into each of the original files worksheets.
The data is setup as tables so I need to leave the first row headers in place.
This is what I'm using now (see below), but I read that there is a better way to do it with something like this.
Workbooks("File1.xls").Sheets("Sheet1").range("A1").Copy Workbooks("File2.xls").Sheets("Sheet2").range("A1")
The problem I have is I don't know how to copy everything except the first row. With the code I'm currently using I recorded a macro that goes to cell A2 and uses CMD+SHF+END to grab all the data.
Thanks in advance for any help you can give me.
Sub UpdateData()
'
' UpdateData Macro
Application.ScreenUpdating = False
' Clear current data.
Sheets("ClientInfo").Select
Rows("2:" & Rows.Count).ClearContents
Sheets("Quotes").Select
Rows("2:" & Rows.Count).ClearContents
Sheets("PolicyPlanData").Select
Rows("2:" & Rows.Count).ClearContents
Sheets("EstimatedPremium").Select
Rows("2:" & Rows.Count).ClearContents
'Open Data file.
Workbooks.Open Filename:= _
"W:\My File Cabinet\cndjrdn\BGA\ClientBio\ClientData.xls"
'Copy data into each worksheet.
Application.CutCopyMode = False
Windows("ClientData.xls").Activate
Application.GoTo Sheets("ClientInfo").Range("A2")
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("BGA Client Bio May2016v4.xlsx.xlsm").Activate
Application.GoTo Sheets("ClientInfo").Range("A2")
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
Windows("ClientData.xls").Activate
Application.GoTo Sheets("Quotes").Range("A2")
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("BGA Client Bio May2016v4.xlsx.xlsm").Activate
Application.GoTo Sheets("Quotes").Range("A2")
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
Windows("ClientData.xls").Activate
Application.GoTo Sheets("PolicyPlanData").Range("A2")
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("BGA Client Bio May2016v4.xlsx.xlsm").Activate
Application.GoTo Sheets("PolicyPlanData").Range("A2")
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
Windows("ClientData.xls").Activate
Application.GoTo Sheets("EstimatedPremium").Range("A2")
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("BGA Client Bio May2016v4.xlsx.xlsm").Activate
Application.GoTo Sheets("EstimatedPremium").Range("A2")
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A2").Select
'Refresh PivotTable(s)
ThisWorkbook.RefreshAll
'Close Data File
Windows("ClientData.xls").Activate
ActiveWorkbook.Close SaveChanges:=False
End Sub
.Select
– BruceWayne