meadscarla
New Member
- Joined
- Apr 3, 2013
- Messages
- 7
I am trying to assign a unique, consecutive value to cells in column D based on the value in the corresponding cell in column A. Wherever the cell in Column A equals "New", a value should be populated into the cell in column D.
This value should be a user defined code of letters followed by 0001, 0002, 0003 etc.
i.e. I am trying to achieve this:
<tbody>
</tbody>
The user defined code of letters is input via an input box. Here is what I have so far.
Obviously this just places ABC0001 in each cell in column D so I am looking for how I can ensure each value is the next consecutive number.
Thanks.
This value should be a user defined code of letters followed by 0001, 0002, 0003 etc.
i.e. I am trying to achieve this:
A | D |
New | ABC0001 |
Old | |
Changed | |
Old | |
New | ABC0002 |
New | ABC0003 |
Old | |
New | ABC0004 |
<tbody>
</tbody>
The user defined code of letters is input via an input box. Here is what I have so far.
Code:
InterimCode = InputBox("Please enter code for Interim Number")
Range("D1").Select
Do
ActiveCell.Offset(1, 0).Range("A1").Select
If ActiveCell.Offset(0, -3).Range("A1") = "New" Then
ActiveCell.FormulaR1C1 = InterimCode & "0001"
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Loop Until IsEmpty(ActiveCell.Offset(0, -3))
Obviously this just places ABC0001 in each cell in column D so I am looking for how I can ensure each value is the next consecutive number.
Thanks.