What I'm attempting to do: copy all the rows from an open workbook, insert them into my other workbook that is a template, between to placeholders with formulas. my data in the template goes from A:CE. I've got the first part working where I insert the rows, but I don't know how to paste formats and formulas to a row where I don't always know the final number. Sometimes it's row 405 sometimes it's row 49850.
As far as I can tell, this last part is pretty useless. That's what I've managed to gather across the internet. I need to copy the formats in B2:CE2 down to the final row, then I need to copy the actual formulas in AK2:CE2 down to the last row, then I need to delete my dummy row that was used in Row 2 and the last row that was previously a placeholder in row 3. Full disclosure - i have no idea what i'm really doing.
Any help is appreciated.
VBA Code:
Sub StripData()
Dim myWb As Workbook
Dim myRowsToCopy As Range
Set myWb = Workbooks.Open("C:\Users\User\Desktop\Practice\Data_Pull_Dummy.xlsx")
With myWb.Sheets("Data").Range("A:XFD")
Set myRowsToCopy = Range(.Cells(.Rows.Count, 1).End(xlUp), .Cells(2, .Columns.Count))
End With
myRowsToCopy.Copy
Workbooks("Template.xlsm").Worksheets("Raw").Range("3:3").Insert Shift:=xlDown
Application.CutCopyMode = False
Dim lastrow As Range
Set lastrow = Workbooks("Template.xlsm").Worksheets("Raw").Cells(Rows.Count, 1).End(xlUp).Offset(1)
Workbooks("Template.xlsm").Worksheets("Raw").Range("B2:CE2").Copy
Do Until WorksheetFunction.CountA(lastrow.EntireRow) = 0
Workbooks("Template.xlsm").Worksheets("Raw").Range("B3:CE3").End(xlDown).PasteSpecial Paste:=xlPasteFormats
Set lastrow = lastrow.Offset(1)
Application.CutCopyMode = False
Loop
End Sub
As far as I can tell, this last part is pretty useless. That's what I've managed to gather across the internet. I need to copy the formats in B2:CE2 down to the final row, then I need to copy the actual formulas in AK2:CE2 down to the last row, then I need to delete my dummy row that was used in Row 2 and the last row that was previously a placeholder in row 3. Full disclosure - i have no idea what i'm really doing.
Any help is appreciated.