I am working on a project where I have been given a worksheet that was originally subtotals that have been pasted as values into another sheet. My task is to fill the values in columns B to E with the subtotal values. I was trying to write a loop that would start at the last value in the column and work its way up. I know I want it to look at this criteria, but I am not sure how to put it into VBA.
If B,row = “Grand” delete entire row
If B,Row has a value, check to see if the next row up has a value
If it does, then move to the next row, if it does not then copy the paste the value into the new cell.
I have this code started, but then I got lost.
r = Range(“B” & Rows.Count).End(xlUp).Row
For n = r To 1 Step -1
If (Cells(n, 2) = “Grand”) _
Then
Cells(n, 1).EntireRow.Delete
Else
If (Cells(n – 1, 2) > 0) _
Then
Else
Cells(n, 2).Copy
Cells(n – 1, 2).Paste
End If
Next n
End Sub
Any help would be appreciated. I have attached a sample of the data.