RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 810
- Office Version
- 365
- Platform
- Windows
Hi all,
I'm counting the number of PU's, which I've set as "PUdonk = 0" then later, "PUdonk = PUdonk + 1"
What I'm trying to achieve is the first time it finds "Rail" 2 cells below the active cell, it names the value one cell below the active cell as "PU1" (because 0+1 is 1)
Then when it finds the second value of Rail, it names the next cell "PU2"
And so on
The trouble is the last line "PU" & PUdonk...." is highlighted with the error: "Compile error: Expected: line number of label or statement or end of statement"
Any ideas? In my head, this was very straightforward :')
Ah, after more googling, this can't be done.
Instead I've created a helper row which will be named "PU1" "PU2" etc and I will just reference them in that fashion.
I'm counting the number of PU's, which I've set as "PUdonk = 0" then later, "PUdonk = PUdonk + 1"
Code:
Do Until Cells(ActiveCell.Row, "B").Value = "" If ActiveCell.Offset(2, 0).Value = "Rail" Then
PUdonk = PUdonk + 1
"PU" & PUdonk = ActiveCell.Offset(1, 0).Value
End If
Loop
What I'm trying to achieve is the first time it finds "Rail" 2 cells below the active cell, it names the value one cell below the active cell as "PU1" (because 0+1 is 1)
Then when it finds the second value of Rail, it names the next cell "PU2"
And so on
The trouble is the last line "PU" & PUdonk...." is highlighted with the error: "Compile error: Expected: line number of label or statement or end of statement"
Any ideas? In my head, this was very straightforward :')
Ah, after more googling, this can't be done.
Instead I've created a helper row which will be named "PU1" "PU2" etc and I will just reference them in that fashion.
Last edited: