Solved

extract numeric from text string

Posted on 2014-04-28
3
311 Views
Last Modified: 2014-04-28
I have text strings and I would like to be able to extract only the number contained within.

ie
GSX-R 1100 M (GSX-R M), GSX-R 1100 N (GSX-R N) = 1100
GSX 750/K1/W/X/Y= 750

GZ 125 K=125

am with microsoft 365 version and working in query grid.

help would be appreciated.
0
Comment
Question by:PeterBaileyUk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 40026780
This function will return the numeric part of a string:
Function fExtractText(ByVal strInput As String) As String
    With CreateObject("VBScript.RegExp")
        .Pattern = "\D+"
        .Global = True
        fExtractText = .Replace(strInput, "")
    End With
End Function

Open in new window


Sample usage:
Sub Demo
    MsgBox(fExtractText("GSX-R 1100 M (GSX-R M)"))
End Sub

Open in new window

0
 
LVL 8

Expert Comment

by:Ganapathi
ID: 40026841
Function ExtractNumbers(ByVal str As String) As String
    num = ""
    For x As Integer = 0 To str.Length - 1
        If IsNumeric(str.Substring(x, 1)) Then num = num & str.Substring(x, 1)
    Next
    return num
End Function

Open in new window

0
 

Author Closing Comment

by:PeterBaileyUk
ID: 40026880
thx
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question