Hello,
I'm very new to VBA but do my best to search pre-existing solutions.
I have a spreadsheet with multiple columns. For each column, I have a formula in row 5 that I want copied down in the entire column below. The paste range would actually start with row 8.
A very plain but inefficient way to do that is to repeat the below code for all my columns (change col reference in range) but they're quite a few and it takes ages to run:
Sub Macro3()
Dim last_row As Long
Range("H5").Select
Selection.Copy
Range("H8").Select
ActiveSheet.Paste
Application.CutCopyMode = False
last_row = Cells(Rows.Count, 6).End(xlUp).Row
Range("H8").AutoFill Destination:=Range("h8:h" & last_row)
End Sub
I'm looking for a way to loop this action through this array of columns: (8, 11, 14, 17, 20, 23, 27, 30, 33, 36, 39, 42, 45, 47). I've read on For Each statements, but I don't know how to build in the actually code for the formula to be copied from row 5 (above each column header) to the rest of the column, for each column.
Any help would be much appreciated!
Thanks,
Oana
I'm very new to VBA but do my best to search pre-existing solutions.
I have a spreadsheet with multiple columns. For each column, I have a formula in row 5 that I want copied down in the entire column below. The paste range would actually start with row 8.
A very plain but inefficient way to do that is to repeat the below code for all my columns (change col reference in range) but they're quite a few and it takes ages to run:
Sub Macro3()
Dim last_row As Long
Range("H5").Select
Selection.Copy
Range("H8").Select
ActiveSheet.Paste
Application.CutCopyMode = False
last_row = Cells(Rows.Count, 6).End(xlUp).Row
Range("H8").AutoFill Destination:=Range("h8:h" & last_row)
End Sub
I'm looking for a way to loop this action through this array of columns: (8, 11, 14, 17, 20, 23, 27, 30, 33, 36, 39, 42, 45, 47). I've read on For Each statements, but I don't know how to build in the actually code for the formula to be copied from row 5 (above each column header) to the rest of the column, for each column.
Any help would be much appreciated!
Thanks,
Oana