Hi everyone,
I'm a complete novice at excel and vba. If you see the attached worksheet, my goal was to have a code that would fill each blank cell in columns A and B with the sum of the cells before it, until it reached another blank cell. I searched online and have found a code that works, see below, however it is a defined range. I will be inputting new data daily and therefore need it to automatically adjust the range to the last row in the table. I've searched the internet for a couple of weeks now trying to find a solution that works to no avail. My current code is:
Sub PickingTotals()
Dim myCell As Range
Dim currentSum As Double
For Each myCell In Worksheets("ALL DATA").Range("a2:a287,b2:b287")
If myCell = vbNullString Then
myCell = currentSum
myCell.Interior.Color = 16777215
currentSum = 0
Else
currentSum = currentSum + myCell
End If
Next myCell
End Sub
Bookmarks