Re: Removing characters from a cell (keeping only numbers) 2

Tech-Archive recommends: Fix windows errors by optimizing your registry



Put this code in a REGULAR module and then

=striptxt(a1)

Function StripTxt(a As String) As String
' Strips all non-numeric characters from a string
' Returns a string, not a number!
Dim i As Long
Dim b As String
For i = 1 To Len(a)
b = Mid$(a, i, 1)
If Asc(b) > 47 And Asc(b) < 58 Then StripTxt = StripTxt + b
Next i
End Function



--
Don Guillett
SalesAid Software
dguillett1@xxxxxxxxxxxxx
"Monk" <Monk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A80F0730-0CC5-4FFE-8168-9FFD34816E1E@xxxxxxxxxxxxxxxx
> Hello..
>
> I did post this question yesterday and following a fantastic response I
> thought I had it rapid up..
> However the cool formula provided has a slight defect to it..
>
> Ok.. The problem..., I have a vast list of cells with numbers with in them
> (which is good) however the string of numbers sometimes commence with the
> 'character and sometimes may end with a 'character or both in some cases,
> (which is bad).
>
> Example A1: '1234435999 A2: 34566673341 A3: '444532322711'
>
> It appears completely random whether the cells contain any 'character or
> is
> completely free from the little blighters.
> So I need a formula (rather then macro) to remove all the '''' characters
> in
> one go (rather then using the longwinded Left / Right formula)
>
> Yesterday I was given the following impressive formula.
> B1
> =LEFT(MID(P29,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},P29&"0123456789")),MAX(SEARCH({0,1,2,3,4,5,6,7,8,9},"0123456789"&P29))),SUMPRODUCT(--ISNUMBER(--MID(P29,ROW(INDIRECT("1:"&(LEN(P29)))),1))))
>
> This appeared to work perfectly, however I have since noticed if the cell
> ENDS with any consecutive digits (ie. 35999) the formula only appears to
> generate one of the digits (359). Can anyone amend the formula or provide
> a
> new one to get around my dilemma ..?
>
> Many thanks,
> Monk
>


.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)