This is a bit of a trivial error but I cannot figure it out. I have a vba script that is copying and pasting a couple of items. It works on all but the last. The error is
The information cannot be pasted because the Copy area and the paste
area are not the same size and shape. Try one of the following:
- Click a single cell, and then paste. •
- Select a rectangle that’s the same size and shape, and then paste.
Here is the code:
Sub MakePropertyPage(propertyNum, aFile)
Dim sheetName As String
sheetName = "Prop " & propertyNum
'OPENS INDIVIDUAL WORKBOOKS TO PULL IN INPUT INFORMATION
Workbooks.Open Filename:=vpath & ThisWorkbook.Path & "\" & aFile & ".xlsb", UpdateLinks:=False, ReadOnly:=True
Dim sourceRangeAsString As String, dest As Range, clearArea As Range
Dim sheetToEdit As Worksheet
Set sheetToEdit = ThisWorkbook.Sheets(sheetName)
Set clearArea = sheetToEdit.Range("AL100:CC900")
clearArea.Delete
sourceRangeAsString = "RentRoll"
Set dest = sheetToEdit.Range("AL100")
Call CopyAndPaste(Workbooks(aFile & ".xlsb"), sourceRangeAsString, dest)
sourceRangeAsString = "Underwriting"
Set dest = sheetToEdit.Range("AL300")
Call CopyAndPaste(Workbooks(aFile & ".xlsb"), sourceRangeAsString, dest)
sourceRangeAsString = "Projections"
Set dest = sheetToEdit.Range("AL400")
Call CopyAndPaste(Workbooks(aFile & ".xlsb"), sourceRangeAsString, dest)
sourceRangeAsString = "RolloverCalculations"
dest = sheetToEdit.Range("AL500")
Call CopyAndPaste(Workbooks(aFile & ".xlsb"), sourceRangeAsString, dest)
'Close the workbook now that we are done with it
Workbooks(aFile & ".xlsb").Close savechanges:=False
End Sub
Sub CopyAndPaste(sourceFile, sourceRangeAsString, dest)
Set source = sourceFile.Names(sourceRangeAsString).RefersToRange
source.Copy
dest.PasteSpecial (xlPasteValues)
source.Copy
dest.PasteSpecial (xlPasteFormats)
End Sub
You’re missing a
Sethere: