Truncate a cell value

  • Thread starter Thread starter Bishop
  • Start date Start date
B

Bishop

Say I have a cell with "_PF3" in it. I want to assign just the 3 to a
variable. How do I do that? All the cells I'm working with will be like
this: _PF23, _PF15, _PF8, etc. I want to assign just the number value in the
cell without the _PF part.
 
To follow up on Bob's response... Bob is assuming the "_PF3" in your first
example has no other text in the cell. If, on the other hand, your cell has
text that *ends in* "_PF3" with other text that precedes it, then try this
instead...

myVar = Split(Range("A2").Value, "_PF",,vbTextCompare)(1)
 
Back
Top