Hi all,
I have 2 columns as follows:
1200___1800
0______0
1200___1800
1200___1800
1200___1800
1200___1800
0______0
1200___1800
And I want to make the numbers between the zeros zero also (so it looks like:
1200___1800
0______0
0______0
0______0
0______0
0______0
0______0
1200___1800
I created the following macro:
Sub replace()
Dim iRow As Integer, iCol As Integer
For iRow = 16 To 279
For iCol = 17 To 18
If Cells(iRow, iCol) <> 0 And Cells(iRow - 1, iCol) = 0 Then
Cells(iRow, iCol) = 0
Else
Cells(iRow, iCol) = Cells(iRow, iCol)
End If
Next iCol
Next iRow
End Sub
The problem I am having is everthing below the first zero becomes zero (which makes sense as it would see any non zero with a zero above and make it a zero).
Any ideas how to alter this macro to make it look for the first occurence of a zero value, and then make everthing in the 2 columns zero until it hits the next zero, and then leave it unchanged?
Cheers
John
I have 2 columns as follows:
1200___1800
0______0
1200___1800
1200___1800
1200___1800
1200___1800
0______0
1200___1800
And I want to make the numbers between the zeros zero also (so it looks like:
1200___1800
0______0
0______0
0______0
0______0
0______0
0______0
1200___1800
I created the following macro:
Sub replace()
Dim iRow As Integer, iCol As Integer
For iRow = 16 To 279
For iCol = 17 To 18
If Cells(iRow, iCol) <> 0 And Cells(iRow - 1, iCol) = 0 Then
Cells(iRow, iCol) = 0
Else
Cells(iRow, iCol) = Cells(iRow, iCol)
End If
Next iCol
Next iRow
End Sub
The problem I am having is everthing below the first zero becomes zero (which makes sense as it would see any non zero with a zero above and make it a zero).
Any ideas how to alter this macro to make it look for the first occurence of a zero value, and then make everthing in the 2 columns zero until it hits the next zero, and then leave it unchanged?
Cheers
John