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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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! |
Truncate
Thanks!!!!!
|
All times are GMT +1. The time now is 10:26 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com