Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Truncate Left Characters in Cell Value Ray Clark[_2_] Excel Programming 4 December 26th 07 11:00 PM
Truncate value of a cell Nde Excel Programming 1 June 27th 07 10:13 PM
Truncate within a cell [email protected] Excel Worksheet Functions 11 September 14th 06 02:21 PM
Truncate Cell text all the time [email protected] Excel Programming 1 October 27th 05 05:48 PM
truncate data on cell ? Rich[_16_] Excel Programming 1 November 8th 03 03:50 AM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"