inigomontoya
New Member
- Joined
- Apr 24, 2009
- Messages
- 15
I need a VBA code that looks for an empty row and assigns a formula to certain cells on that row which total all the cells above it up to the previous empty row.
I need to do this for quite a few contiguous cells (columns D-AA).
Here's my code that is not working:
Also, I would like to format the entire row as well. I need to shade it a certain color.
Please help!
IM
I need to do this for quite a few contiguous cells (columns D-AA).
Here's my code that is not working:
Code:
Sub Totals()
Dim LR As Long
Dim i As Long
Dim j As Long
Dim x As Long
x = 4
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 5 To LR
If Range("A" & i).Value = Empty Then
For j = 4 To 27 Step 1
Range(i, j).Formula = "=SUM(i-1, j : x, j)"
Next j
x = i
End If
Next i
End Sub
Also, I would like to format the entire row as well. I need to shade it a certain color.
Please help!
IM