RobertCotton
Board Regular
- Joined
- Nov 1, 2010
- Messages
- 99
I'm trying to write a macro that will sequentially number a column based on the valuse in 2 other columns. I have accomplished most of what I want to do with the following code.
Sub MacroCounter()
Dim Rank As Integer
Dim INum As Integer
Rank = ActiveCell
ActiveCell.Select
INum = 1
Do Until ActiveCell = 0
If ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) = 1 Then
ActiveCell.Offset(0, 1) = INum
Else
ActiveCell.Offset(0, 1) = ""
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
I need to enforce the rule that if the value of ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) is zero then I want ActiveCell.Offset(0, 1) to be null. However, when the loop restarts if the value ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) is 1 I want the next sequential number.
This macro populates all cells as either 1 or null.
Can anyone help me with this?
Sub MacroCounter()
Dim Rank As Integer
Dim INum As Integer
Rank = ActiveCell
ActiveCell.Select
INum = 1
Do Until ActiveCell = 0
If ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) = 1 Then
ActiveCell.Offset(0, 1) = INum
Else
ActiveCell.Offset(0, 1) = ""
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
I need to enforce the rule that if the value of ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) is zero then I want ActiveCell.Offset(0, 1) to be null. However, when the loop restarts if the value ActiveCell.Offset(0, 12) + ActiveCell.Offset(0, 13) is 1 I want the next sequential number.
This macro populates all cells as either 1 or null.
Can anyone help me with this?