Thread: Truncate
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy[_2_] Tom Ogilvy[_2_] is offline
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