Macro for Sequential Numbering.

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?
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
you need to increment your value after it puts the number. That way if your main cell equals 1, it will increment it for next time, if not, it drops to your ELSE and stays the same.

ActiveCell.Offset(0, 1) = INum

INum = INum + 1

Else
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top