This should grab a range in the copyworkbooks then paste it to the master:
Sub activateMacro()
Dim masterWKB, copyWKB As Workbook
Set masterWKB = ThisWorkbook
Dim masterWKS, copyWKS As Worksheet
Set masterWKS = Worksheets("Data")
Dim lastLineCopy, lastLineWKB As Long
Dim pasteRange As Range
Dim listofFileNames As Variant
listofFileNames = buildfilenameArray
for i = 0 to Ubound(listofFileNames)
lastLineWKB = masterWKS.Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row + 1
Debug.Print lastLineWKB
Set copyWKB = Workbooks.Open("c:temp\" & listofFileNames(i, 0) & "")
lastLineCopy = copyWKB.Sheets(1).Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row
Debug.Print lastLineCopy
copyWKB.Sheets(1).Range("A15:AG" & lastLineCopy & "").Copy
masterWKB.masterWKS.Range(masterWKS.Cells(lastLineWKB, 1)).PasteSpecial
Next
end sub
I'm erroring out with object doesn't support his property or method at:
masterWKB.masterWKS.Range(masterWKS.Cells(lastLineWKB, 1)).PasteSpecial
and I'm not sure why.
EDIT:
Got it to work with this but I wanted to avoid using activate.
masterWKB.Activate
masterWKS.Range("A" & lastLineWKB & "").PasteSpecial
Just change the line with the error to this:
For some reason, when you use
Cells
inside ofRange
, you have to specify both the beginning and ending cell of the range (even if they're the same cell). A single cell reference will give the error you described. Try:masterWKB.masterWKS.Range(masterWKS.Cells(lastLineWKB, 1),masterWKS.Cells(lastLineWKB, 1)).PasteSpecial