Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Robert,
Am Wed, 20 Nov 2019 10:48:20 -0800 (PST) schrieb RG III: I have a set of strings that contain digits at the right end, such as: s1 = "abcd1234" s2 = "g10" s3 = "yyy19123" The data will always contain alpha chars on the left, and digits on the right. try: For i = 1 To Len(s2) If Asc(Mid(s2, i, 1)) 47 And Asc(Mid(s2, i, 1)) < 58 Then myNumber = CInt(Mid(s2, i)) Exit Sub End If Next or: Sub Test2() Dim re As Object, Match As Object Dim ptrn As String s1 = "abcd1234" s2 = "g10" s3 = "yyy19123" ptrn = "[\d]{1,}" Set re = CreateObject("vbscript.Regexp") re.pattern = ptrn re.IgnoreCase = False re.Global = True Set Match = re.Execute(s3) MsgBox Match(0).Value End Sub Regards Claus B. -- Windows10 Office 2016 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I extract the last three digits from each cell in column? | Excel Discussion (Misc queries) | |||
To extract the number if there is niumeric in right most digits | Excel Discussion (Misc queries) | |||
how to extract digits from a row of numbers | Excel Worksheet Functions | |||
I need to extract the first 3 digits from a cell (ex: AAG12345)? | Excel Worksheet Functions | |||
Extract Digits Questions | Excel Programming |