Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 102
Default How do I strip just numbers from an alphanumeric cell?

I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default How do I strip just numbers from an alphanumeric cell?

This is simple; somewhat crude:
Function reNums(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
reNums = re.Replace(str, "")
End Function

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Benjamin" wrote:

I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default How do I strip just numbers from an alphanumeric cell?

On Mon, 5 Oct 2009 13:44:02 -0700, ryguy7272
wrote:

This is simple; somewhat crude:
Function reNums(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
reNums = re.Replace(str, "")
End Function

HTH,
Ryan---


He only wanted that final digits:

so something like

re.pattern = ".*-\D*(\d+).*"

and

reNums = re.replace(str,"$1")

--ron
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How do I strip just numbers from an alphanumeric cell?

Or, without using RegExp, this one-liner UDF...

Function FindLastNumber(S As String) As Variant
FindLastNumber = Val(Mid(S, InStrRev(S, "-") + 1))
End Function

--
Rick (MVP - Excel)


"ryguy7272" wrote in message
...
This is simple; somewhat crude:
Function reNums(str As String)
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "\D"
reNums = re.Replace(str, "")
End Function

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Benjamin" wrote:

I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 542
Default How do I strip just numbers from an alphanumeric cell?

check out
http://www.ozgrid.com/VBA/ExtractNum.htm

"Benjamin" wrote:

I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default How do I strip just numbers from an alphanumeric cell?

Maybe this formula...

=LOOKUP(9.9E+307,--LEFT(TRIM(RIGHT(SUBSTITUTE(
A2,"-",REPT(" ",99)),99)),ROW($1:$99)))

--
Rick (MVP - Excel)


"Benjamin" wrote in message
...
I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default How do I strip just numbers from an alphanumeric cell?

On Mon, 5 Oct 2009 13:09:01 -0700, Benjamin
wrote:

I need to strip just the numbers after the last -
RV01-HYC0246-43-T-892A i.e. 892
RV01-HYC0246-43-H-892 i.e. 892
I know how to use the Right(and find("")) commands.
Any help on just numeric character and not alphas?


From your example, it appears that you want a function that will "return" the
last numbers in a <space separated string, and that this last entry might have
letters also. However, the last entry always starts with a number.

If that is the case, you can use this formula:

=LOOKUP(1E+307,--MID(TRIM(RIGHT(SUBSTITUTE(
A1,"-",REPT(" ",99)),99)),1,ROW(INDIRECT("1:10"))))

--ron
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
separating numbers from a alphanumeric cell Igneshwara reddy[_2_] Excel Worksheet Functions 3 March 12th 07 08:13 PM
extract numbers from a alphanumeric cell Igneshwara reddy Excel Worksheet Functions 4 February 27th 07 06:24 PM
Function to extract numbers from an alphanumeric cell diana Excel Worksheet Functions 4 March 13th 06 09:55 AM
separating numbers and letters from alphanumeric cell contents PH Excel Worksheet Functions 10 September 3rd 05 12:15 PM
Sorting alphanumeric numbers maurice.centner Excel Discussion (Misc queries) 2 May 6th 05 02:00 AM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"