#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Hell
Im trying to pices together code from here that will truncate the text to the left of and including "/"
This is what I have so far but it isnt working.

Sub Truncat

Dim rng As Rang
Dim c As Rang
Set rng = Selectio
For Each c In rn
c.Value = Left(ActiveCell.Value, InStr(1, ActiveCell.Value, "/") - 1
Nex
End Su

All help is greatly appreciated
Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Truncate

Hi Steve
try
Sub Truncate

Dim rng As Range
Dim c As Range
Set rng = Selection
For Each c In rng
c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1)
Next
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Steven wrote:
Hello
Im trying to pices together code from here that will truncate the
text to the left of and including "/". This is what I have so far but
it isnt working.

Sub Truncate

Dim rng As Range
Dim c As Range
Set rng = Selection
For Each c In rng
c.Value = Left(ActiveCell.Value, InStr(1, ActiveCell.Value,
"/") - 1) Next
End Sub

All help is greatly appreciated.
Steven


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Truncate

Try substituting "c" for "ActiveCell".

--

Vasant

"Steven" wrote in message
...
Hello
Im trying to pices together code from here that will truncate the text to

the left of and including "/".
This is what I have so far but it isnt working.

Sub Truncate

Dim rng As Range
Dim c As Range
Set rng = Selection
For Each c In rng
c.Value = Left(ActiveCell.Value, InStr(1, ActiveCell.Value, "/") -

1)
Next
End Sub

All help is greatly appreciated.
Steven



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Thanks Fran
I had tried that and I am getting "Invalid Procedure Call" on

c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1

Thanks again
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Thanks Fran
I had tried that and I am getting "Invalid Procedure Call" on

c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1

Thanks again


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Truncate

You might want to check that the cell actually contains a "/" or yo
might get unpleasant results/error.

Sub Truncate

Dim rng As Range
Dim c As Range
Set rng = Selection
For Each c In rng
if instr(1,c.value,"/") < 0 then
c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1)
End if
Next
End Sub

if the cells contain dates, you might want to change Value to Text

--
Regards,
Tom Ogilv

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Truncate

That is because you cell doesn't contain a "/", at least the value property
doesn't

try putting in a text

if instr(1,c.value,"/") < 0 then
c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1)
End if

--
Regards,
Tom Ogilvy

"Steven" wrote in message
...
Thanks Frank
I had tried that and I am getting "Invalid Procedure Call" on

c.Value = Left(c.Value, InStr(1, c.Value, "/") - 1)

Thanks again



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Thanks To
That worked as posted---now I realize I need to save to right of "/" so what would the modification be....
Thanks for all of your help
Steven
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Thanks To
That worked as posted---now I realize I need to save to right of "/" so what would the modification be....
Thanks for all of your help
Steven
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Truncate

Sub Truncate

Dim rng As Range
Dim c As Range
Dim ln as Long
Set rng = Selection
For Each c In rng
if instr(1,c.value,"/") < 0 then
c.Value = Mid(c.Value, InStr(1, c.Value, "/") + 1 ,255)
' '''or
' ln = len(c.value) - instr(1,c.Value,"/")
' c.Value = Right(c.Value,ln)
End if
Next
End Sub

--
Regards,
Tom Ogilvy

"Steven" wrote in message
...
Thanks Tom
That worked as posted---now I realize I need to save to right of "/" so

what would the modification be.....
Thanks for all of your help!
Steven





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

I cant get my left and right straight. I need to save to the left of the "/" EG. I am stupid/YES/NO...tuncated gives ..
I am stupid

Thanks!
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Truncate

Thanks!!!!!
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 Elizabeth Excel Discussion (Misc queries) 4 November 18th 09 09:50 PM
truncate chart Mike of Book Worm Angels Charts and Charting in Excel 1 May 2nd 08 01:51 PM
How do you truncate 2.22 to just 0.22? Crackles McFarly Excel Worksheet Functions 6 September 5th 07 01:14 AM
How do I truncate something like this? ckeys Excel Discussion (Misc queries) 6 December 30th 06 05:49 PM
truncate tamar Excel Worksheet Functions 1 July 19th 05 10:32 PM


All times are GMT +1. The time now is 07:41 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"