Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Trim the last two characters?

Hi folks,
I'm new to VBA, but I've programmed in VB (a little bit)
before. I have several cells that I simply need to trim
off the last 2 characters from. Is there a function in
Excel that can do that?...or does someone know of a
function that will do that? I frequently have something
like: 373.62CR and I need to keep the numeric portion, but
lose the text portion. Suggestions???

Thanks,
Craig

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trim the last two characters?

Is the CR produced by formatting or is this actually part of the value of
the cell. If you select the cell is it shown in the formula bar?

Assuming it is part of the text in the cell

Sub Remove2()
for each cell in selection
if not cell.Hasformula then
cell.Value = Left(cell.value,len(Cell.Value)-2)
end if
Next
End Sub

Assume the value is in A1, in B1 =Left(A1,len(A1)-2)

then drag fill down the column.

--
Regards,
Tom Ogilvy

"Craig" wrote in message
...
Hi folks,
I'm new to VBA, but I've programmed in VB (a little bit)
before. I have several cells that I simply need to trim
off the last 2 characters from. Is there a function in
Excel that can do that?...or does someone know of a
function that will do that? I frequently have something
like: 373.62CR and I need to keep the numeric portion, but
lose the text portion. Suggestions???

Thanks,
Craig



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Trim the last two characters?

have you tried left(ref,len(ref)-2)

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Trim the last two characters?

Hi Duane,
No, I haven't. Can you give me an example using the
Cells.Value concept (I don't quite understand the syntax
you've suggested), which is how I would be using it?

Thank you!
Craig


-----Original Message-----
have you tried left(ref,len(ref)-2)?


---
Message posted from http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trim the last two characters?

I gave you an example with cells.value?
what what the problem with it?

--
Regards,
Tom Ogilvy

"Craig" wrote in message
...
Hi Duane,
No, I haven't. Can you give me an example using the
Cells.Value concept (I don't quite understand the syntax
you've suggested), which is how I would be using it?

Thank you!
Craig


-----Original Message-----
have you tried left(ref,len(ref)-2)?


---
Message posted from http://www.ExcelForum.com/

.



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
Trim out last seven characters from a string... DubboPete Excel Discussion (Misc queries) 3 February 2nd 10 05:16 AM
Trim characters Ronbo Excel Worksheet Functions 7 January 26th 09 09:29 PM
Trim hidden characters? robotman Excel Worksheet Functions 3 October 20th 07 12:00 AM
How do you trim characters? Tommi Excel Worksheet Functions 6 January 29th 06 01:38 PM
Trim characters Ange[_3_] Excel Programming 1 August 25th 04 07:31 PM


All times are GMT +1. The time now is 07:53 PM.

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"