rahildhody
New Member
- Joined
- Aug 4, 2016
- Messages
- 41
Hi all,
I've been trying to copy sections from "Template" sheet & paste it in the "Output" sheet as per the attached file.
The sections are highlighted in yellow and I have produced how I would like the "Output" sheet to ultimately look like once the macro is completed. I'd like to copy all of the yellow highlighted sections from the "Template" sheet and keep pasting in the last found row in the "Output" sheet. Copying has to occur till row 637.
I can write the code to copy "B84:E87", paste in Output sheet ("B3:E6"), then copy "O84:BV87" from Template sheet & paste in output sheet ("F3:BM6"), then repeat the process for the next section "B109:E112" & "O109:BV112" in template sheet and paste in the next found lastrow (row7) in output sheet and keep repeating until all yellow highlighted sections until row 637 have been copied from the template sheet into the output sheet.
Would appreciate any help in generating this code that is more efficient than the code above.
I've been trying to copy sections from "Template" sheet & paste it in the "Output" sheet as per the attached file.
The sections are highlighted in yellow and I have produced how I would like the "Output" sheet to ultimately look like once the macro is completed. I'd like to copy all of the yellow highlighted sections from the "Template" sheet and keep pasting in the last found row in the "Output" sheet. Copying has to occur till row 637.
I can write the code to copy "B84:E87", paste in Output sheet ("B3:E6"), then copy "O84:BV87" from Template sheet & paste in output sheet ("F3:BM6"), then repeat the process for the next section "B109:E112" & "O109:BV112" in template sheet and paste in the next found lastrow (row7) in output sheet and keep repeating until all yellow highlighted sections until row 637 have been copied from the template sheet into the output sheet.
VBA Code:
'''''Section 1
Sheets("Template").range("B84:E87").copy
Sheets("Output").range("B3").PasteSpecial paste:=xlpasteValues
Sheets("Template").range("O84:BV87").copy
Sheets("Output").range("F3").PasteSpecial paste:=xlpasteValues
lastrow = Sheets("Output").Range("B" & .Rows.Count).End(xlUp).Row
''''lastrow = 6
'''''Section 2
Sheets("Template").range("B109:E112").copy
Sheets("Output").range("B" & lastrow+1).PasteSpecial paste:=xlpasteValues
Sheets("Template").range("O109:BV112").copy
Sheets("Output").range("F" & lastrow+1).PasteSpecial paste:=xlpasteValues
lastrow = Sheets("Output").Range("B" & .Rows.Count).End(xlUp).Row
''''lastrow = 10
'''''Section 3
Sheets("Template").range("B119:E122").copy
Sheets("Output").range("B" & lastrow+1).PasteSpecial paste:=xlpasteValues
Sheets("Template").range("O119:BV122").copy
Sheets("Output").range("F" & lastrow+1).PasteSpecial paste:=xlpasteValues
lastrow = Sheets("Output").Range("B" & .Rows.Count).End(xlUp).Row
'''''and so on till all highlighted sections until row 637 have been copied and pasted into Output sheet
Would appreciate any help in generating this code that is more efficient than the code above.