Truncate a cell value

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.
 
R

Rick Rothstein

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top