Hi, I wonder whether someone may be able to help me please.
I'm trying to put a script together which will perform the following.
- Look at the sheets "Enhancements", "Indirect" and "Overheads".
- Find the first blank row where cells in columns B:N are empty.
- Insert a sum formula in each of these columns which sums the rows above starting at row 4.
I've made a start below but unfortunately I recieve a error when I try to run this.
Sub InsertTotals() Dim StartRow As Integer Dim EndRow As Integer Dim ws As WorksheetStartRow = 4 For Each ws In Worksheets(Array("Enhancements", "Indirect", "Overheads")).Range("C3") EndRow = Range("C65536").End(xlUp).Offset(1, 0).Row For i = StartRow To EndRow If Cells(i, "C") = "" And i > StartRow Then Cells(i, "C").Formula = "=SUM(C" & StartRow & ":C" & i - 1 & ")" StartRow = i + 1 End If Next Next ws End Sub
I'm relatively new to VBA, so perhaps the error is quite simple to the more seasoned developer.
I just wondered whether someone may be able to look at this please and offer some guidance on how I may go about acheiving this.
Many thanks and kind regards