ElectricSkywalker
Board Regular
- Joined
- May 27, 2002
- Messages
- 112
Below is one of my first attempts of actually writing my own code. I really want to get my head around this, so I thought I would throw it around to those of you who "Know" this stuff.
Can someone who understands VBA look through the following code, and possibly give me a bit of a tip.
Just to put you in the picture....in Column D, I have about 30 codes running downwards: FF, OE, and blank.
What i want is to assign a new code in Column B with a consecutive number, and the code itself joined together.
So.....
If D1 = "FF"
then I B1 = 1FF
if D2 = "FF"
then B2 = 2FF
if D3 = "OE"
then D2 = 1OE
etc....
The code I came up with is:
(however, I am not sure how to make the code count upwards - i keep getting 1's).
Sub ff()
x = 0
y = 0
Do
If ActiveCell = "" Then End
If ActiveCell = "FF" Then
ActiveCell.Offset(0, -2).Value = x + 1 & "FF"
Else
If ActiveCell = "OE" Then
ActiveCell.Offset(0, -2).Value = y + 1 & "OE"
Else
ActiveCell.Offset(0, -2).Value = " "
End If
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Can someone who understands VBA look through the following code, and possibly give me a bit of a tip.
Just to put you in the picture....in Column D, I have about 30 codes running downwards: FF, OE, and blank.
What i want is to assign a new code in Column B with a consecutive number, and the code itself joined together.
So.....
If D1 = "FF"
then I B1 = 1FF
if D2 = "FF"
then B2 = 2FF
if D3 = "OE"
then D2 = 1OE
etc....
The code I came up with is:
(however, I am not sure how to make the code count upwards - i keep getting 1's).
Sub ff()
x = 0
y = 0
Do
If ActiveCell = "" Then End
If ActiveCell = "FF" Then
ActiveCell.Offset(0, -2).Value = x + 1 & "FF"
Else
If ActiveCell = "OE" Then
ActiveCell.Offset(0, -2).Value = y + 1 & "OE"
Else
ActiveCell.Offset(0, -2).Value = " "
End If
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub