I am trying to create a sheet where the formulas are copied downwards based on non Empty Cells in Column B.
I have two Sheets in my Excel. For the first I have already written a code to copy all formulas as long as there is Data in Column B.
Sub Copy_Formula()
Dim rng As Range
Range("D9:S" & Rows.Count).Clear
Set rng = Range("B8").End(xlDown)
Range(Cells(8, 4), Cells(8, 18)).Copy Destination:=Range(Cells(9, 4), Cells(rng.Row, 18))
With Range(Cells(9, 4), Cells(rng.Row, 18))
.Copy
.PasteSpecial xlPasteAll
End With
Application.CutCopyMode = False
I want to perform the similar operation in Sheet2 for cells b5:d5 as long as there are non empty cells in Column B of Sheet1.
So e.g. if I have filled B8:B578 in Sheet1, the formulas in Sheet2 B5:D5 are copied down 570 times. But I am failing to code the range reference for the different sheets.
This would be a simplified example:
So as you can see the cells B5:D5 in Sheet2 were copy and pasted 3 times