PC Review


Reply
Thread Tools Rate Thread

Delete everything after a certain character

 
 
a.ofaolain@gmail.com
Guest
Posts: n/a
 
      21st Nov 2006
HI hope some one can help
i have been tring to wolr this out myself by reading previous post but
i still none the wiser

i have a column of numbers and what i need to do is is ther is a / in
the field i need to delete it and any numbers after it
can someone please help i have looked at other examples but dont fully
understand what they do

Andy

 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      21st Nov 2006

Sub delslash()
For Each c In Selection
If InStr(c, "/") > 0 Then
c.Value = Left(c, Len(c) - InStr(c, "/"))
End If
Next
End Sub
--
Don Guillett
SalesAid Software
(E-Mail Removed)
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI hope some one can help
> i have been tring to wolr this out myself by reading previous post but
> i still none the wiser
>
> i have a column of numbers and what i need to do is is ther is a / in
> the field i need to delete it and any numbers after it
> can someone please help i have looked at other examples but dont fully
> understand what they do
>
> Andy
>



 
Reply With Quote
 
=?Utf-8?B?QWxvaw==?=
Guest
Posts: n/a
 
      21st Nov 2006
Try this user defined function. If the number is in Cell A1 then in B1 you
will enter =GetNumerator(A1). Copy and paste to other cells as needed.

As far as the function is concerned, you will need to place it in one of the
modules.
The function works by finding out the formula in the cell and then taking
the numerator if the contents of the cell if the cell happen to contain a
formula. The approach is somewhat different if the content of the cell is
text.

Public Function GetNumerator(ByVal v As Range) As Variant
Application.Volatile

Set v = v.Cells(1)
If InStr(v.Formula, "/") > 0 Then
If Left(Left(v.Formula, InStr(v.Formula, "/") - 1), 1) = "=" Then
GetNumerator = Evaluate(Left(v.Formula, InStr(v.Formula, "/") -
1))
Else
GetNumerator = Left(v.Formula, InStr(v.Formula, "/") - 1)
End If
Else
GetNumerator = v.Value
End If
End Function


"(E-Mail Removed)" wrote:

> HI hope some one can help
> i have been tring to wolr this out myself by reading previous post but
> i still none the wiser
>
> i have a column of numbers and what i need to do is is ther is a / in
> the field i need to delete it and any numbers after it
> can someone please help i have looked at other examples but dont fully
> understand what they do
>
> Andy
>
>

 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      21st Nov 2006
You could just take the Val of the string and it will return only the
numerical part before the /

Val("1234/XYZ") returns 1234

Sub SlashDelete()
Dim c As Range
For Each c In Selection
c = Val(c)
Next
End Sub

--
Cheers
Nigel



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI hope some one can help
> i have been tring to wolr this out myself by reading previous post but
> i still none the wiser
>
> i have a column of numbers and what i need to do is is ther is a / in
> the field i need to delete it and any numbers after it
> can someone please help i have looked at other examples but dont fully
> understand what they do
>
> Andy
>



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      21st Nov 2006
Another way is to select the range
edit|replace
what: /* (slash asterisk)
with: (leave blank)
replace all

Be aware that if you have
00012/1313abc
excel will be left with 00012 and that's just the plain old number 12. And
that's what you'll see unless/until you apply formatting to the cell

Like: format|cells|number tab|custom category|00000

(E-Mail Removed) wrote:
>
> HI hope some one can help
> i have been tring to wolr this out myself by reading previous post but
> i still none the wiser
>
> i have a column of numbers and what i need to do is is ther is a / in
> the field i need to delete it and any numbers after it
> can someone please help i have looked at other examples but dont fully
> understand what they do
>
> Andy


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
KeyPress: how to delete last character Paul Martin Microsoft Excel Programming 2 12th Nov 2007 10:56 PM
how do i delete everything after a particular character, after each such character? gilgilgil Microsoft Excel Misc 1 28th Oct 2004 02:53 PM
how do i delete everything after a particular character, after each such character? gilgilgil Microsoft Excel Misc 3 27th Oct 2004 11:31 PM
Delete everything after a certain character? =?Utf-8?B?Q2hyaXM=?= Microsoft Excel Programming 2 18th Jun 2004 09:59 PM
delete last character =?Utf-8?B?VGhlcmVzYQ==?= Microsoft Excel Programming 1 12th Mar 2004 10:12 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:30 PM.