Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Truncate a cell value
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Truncate a cell value
myVar = val(replace(Range("A2").value","_PF",""))
-- __________________________________ HTH Bob "Bishop" wrote in message ... 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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Truncate a cell value
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) -- Rick (MVP - Excel) "Bob Phillips" wrote in message ... myVar = val(replace(Range("A2").value","_PF","")) -- __________________________________ HTH Bob "Bishop" wrote in message ... 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Truncate Left Characters in Cell Value | Excel Programming | |||
Truncate value of a cell | Excel Programming | |||
Truncate within a cell | Excel Worksheet Functions | |||
Truncate Cell text all the time | Excel Programming | |||
truncate data on cell ? | Excel Programming |