H
hnyb1
I am posting again, hoping someone can help...
I have a spreadsheet that does not have a continuous line of data (poor
spreadsheet planning). What I need is a macro that will look in column M for
a "1" and then move over to column T and sum the numbers below, then look for
the next "1" in column M and sum the numbers below in column T. The number
of rows in column T that will need to be totaled will change with every
instance so I was hoping to do some sort of end (xldown) but can't figure out
how to incorporate that into my code (specifically the 6th line of code
below). The code that follows is what I have so far, as you can see it sums
up the following 7 rows for every instance of "1" in column M. I just need
to change that part of the code to sum up the varying number of rows...
Sub cleanup2()
Worksheets("Raw Data").Activate
With ActiveSheet
For i = 10 To 20000
If Cells(i, 13) = "1" And Cells(i + 1, 13) = "" Then
Cells(i, 20).Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C:R[7]C)"
End If
Next
End With
End Sub
Any help would be greatly appreciated. Thanks, Holly
I have a spreadsheet that does not have a continuous line of data (poor
spreadsheet planning). What I need is a macro that will look in column M for
a "1" and then move over to column T and sum the numbers below, then look for
the next "1" in column M and sum the numbers below in column T. The number
of rows in column T that will need to be totaled will change with every
instance so I was hoping to do some sort of end (xldown) but can't figure out
how to incorporate that into my code (specifically the 6th line of code
below). The code that follows is what I have so far, as you can see it sums
up the following 7 rows for every instance of "1" in column M. I just need
to change that part of the code to sum up the varying number of rows...
Sub cleanup2()
Worksheets("Raw Data").Activate
With ActiveSheet
For i = 10 To 20000
If Cells(i, 13) = "1" And Cells(i + 1, 13) = "" Then
Cells(i, 20).Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C:R[7]C)"
End If
Next
End With
End Sub
Any help would be greatly appreciated. Thanks, Holly