Glasgowsmile
Active Member
- Joined
- Apr 14, 2018
- Messages
- 280
- Office Version
- 365
- Platform
- Windows
Good Evening,
I have my coding complete, it works but it's a little sluggish and slow. I'm thinking it could be improved so I wanted to share in case anyone is able to assist in the clean up.
Thanks!
I have my coding complete, it works but it's a little sluggish and slow. I'm thinking it could be improved so I wanted to share in case anyone is able to assist in the clean up.
Thanks!
Code:
Sub FuturePDI()
Sheets("Property Segment Data").Range("B2:I18").Clear
Sheets("Property Segment Data").Range("N4:AC18").Clear
Sheets("Property Segment Data").Range("B21:I34").Clear
Sheets("Property Segment Data").Range("N21:AC34").Clear
Sheets("Property Segment Data").Range("B37:I50").Clear
Sheets("Property Segment Data").Range("N37:AC50").Clear
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("B2:I18").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B2").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B2").PasteSpecial xlPasteFormats
Sheets("Property Segment Data").Range("N4:AC18").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N4").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N4").PasteSpecial xlPasteFormats
Sheets("Property Segment Data").Range("B21:I34").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B21").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B21").PasteSpecial xlPasteFormats
Sheets("Property Segment Data").Range("N21:AC34").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N21").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N21").PasteSpecial xlPasteFormats
Sheets("Property Segment Data").Range("B37:I50").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B37").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("B37").PasteSpecial xlPasteFormats
Sheets("Property Segment Data").Range("N37:AC50").Copy
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N37").PasteSpecial xlPasteValues
wkbCrntWorkBook.Sheets("Property Segment Data").Range("N37").PasteSpecial xlPasteFormats
wkbSourceBook.Close False
End If
End With
Columns("A").EntireColumn.Hidden = True
Rows("1").EntireRow.Hidden = True
Columns("B").ColumnWidth = 23
Columns("C").ColumnWidth = 28
Columns("N").ColumnWidth = 28
Columns("D:L").ColumnWidth = 11
Columns("O:AC").ColumnWidth = 11
End Sub