Glasgowsmile
Active Member
- Joined
- Apr 14, 2018
- Messages
- 280
- Office Version
- 365
- Platform
- Windows
Good Morning,
I've got the following code below to pull data from another spreadsheet. It works fine, no issues but I want the data to look exactly the same in the current workbook I'm using when I pull the data over. How do I keep the formatting consistent so it doesn't expand columns/rows etc?
I've got the following code below to pull data from another spreadsheet. It works fine, no issues but I want the data to look exactly the same in the current workbook I'm using when I pull the data over. How do I keep the formatting consistent so it doesn't expand columns/rows etc?
Code:
Sub PastPDI() Dim wkbCrntWorkBook As Workbook
Dim wkbSourceBook As Workbook
Set wkbCrntWorkBook = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.Filters.Clear
.Filters.Add "Excel 2007-13", "*.xlsx; *.xls; *.xlsm; *.xlsa"
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
Workbooks.Open .SelectedItems(1)
Set wkbSourceBook = ActiveWorkbook
Sheets("Property Segment Data").Range("A1:Z40").Copy wkbCrntWorkBook.Sheets("Sheet1").Range("A1")
wkbCrntWorkBook.Sheets("Sheet1").Range("A1").CurrentRegion.EntireColumn.AutoFit
wkbSourceBook.Close False
End If
End With
End Sub