Problem: In cell A1-A100, I have the following types of data: “ABC 1234-5678”, or “DEF 9012-3456 “, etc. In other words, there is text entered as the first, say, 1-25 characters of a cell, then anywhere from 1 to 50 spaces, then 4 numbers, then a hyphen, then 4 more numbers, then anywhere from 0 to 50 additional spaces. What I would like to do is extract from cells A1:A100 all of the numbers in their original format (i. e., including the hyphen, “1234-5678”, “9012-3456”) into cells B1:B100. Any ideas? Thanks in advance.
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Extracting Numbers from AlphaNumeric Strings
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Extracting Numbers from AlphaNumeric Strings
- This topic has 7 replies, 4 voices, and was last updated 15 years, 1 month ago.
Viewing 4 reply threadsAuthorReplies-
WSrory
AskWoody LoungerApril 28, 2010 at 7:13 am #1220982You could use this UDF:
Code:Function GetNumbers(strInput As String) As String Dim RegExp As Object, match, matches Dim strPattern As String Set RegExp = CreateObject("vbscript.regexp") strPattern = "d{4}-d{4}" With RegExp .Global = True .IgnoreCase = True .Pattern = strPattern Set matches = .Execute(strInput) If matches.Count > 0 Then GetNumbers = matches(0) End With End Function
-
WSjlkirk
AskWoody Lounger -
WSjohnhutchison
AskWoody LoungerApril 28, 2010 at 7:43 am #1220989This post has been cross posted in Another forumwhere another solution has been offered.
-
WSjlkirk
AskWoody LoungerApril 28, 2010 at 8:07 am #1220992This post has been cross posted in Another forumwhere another solution has been offered.
Yes I did post on Eileen’s Lounge where my friend Hans resides now. Although a solution has been offered, it does not do the trick. All I would like to hear from Rory, or anyone for that matter, is how I can possibly get his UDF to work. Plain and simple! No hidden agendas here!
-
WSGfamily
AskWoody LoungerApril 28, 2010 at 8:12 am #1220993Yes I did post on Eileen’s Lounge where my friend Hans resides now. Although a solution has been offered, it does not do the trick. All I would like to hear from Rory, or anyone for that matter, is how I can possibly get his UDF to work. Plain and simple! No hidden agendas here!
Does it need to be a UDF?
You could use a formula such as
=right(trim(A1),9)
-
-
-
WSjlkirk
AskWoody Lounger -
WSrory
AskWoody Lounger
Viewing 4 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows Update orchestration platform to update all software
by
Alex5723
58 minutes ago -
May preview updates
by
Susan Bradley
2 hours, 36 minutes ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
2 hours, 43 minutes ago -
Just got this pop-up page while browsing
by
Alex5723
38 minutes ago -
KB5058379 / KB 5061768 Failures
by
crown
13 hours, 6 minutes ago -
Windows 10 23H2 Good to Update to ?
by
jkitc
15 hours, 45 minutes ago -
At last – installation of 24H2
by
Botswana12
16 hours, 29 minutes ago -
MS-DEFCON 4: As good as it gets
by
Susan Bradley
6 hours, 7 minutes ago -
RyTuneX optimize Windows 10/11 tool
by
Alex5723
1 day, 4 hours ago -
Can I just update from Win11 22H2 to 23H2?
by
Dave Easley
22 hours, 1 minute ago -
Limited account permission error related to Windows Update
by
gtd12345
1 day, 18 hours ago -
Another test post
by
gtd12345
1 day, 18 hours ago -
Connect to someone else computer
by
wadeer
1 day, 12 hours ago -
Limit on User names?
by
CWBillow
1 day, 15 hours ago -
Choose the right apps for traveling
by
Peter Deegan
1 day, 5 hours ago -
BitLocker rears its head
by
Susan Bradley
13 hours, 42 minutes ago -
Who are you? (2025 edition)
by
Will Fastie
12 hours, 39 minutes ago -
AskWoody at the computer museum, round two
by
Will Fastie
1 day, 8 hours ago -
A smarter, simpler Firefox address bar
by
Alex5723
2 days, 4 hours ago -
Woody
by
Scott
2 days, 14 hours ago -
24H2 has suppressed my favoured spider
by
Davidhs
13 hours, 19 minutes ago -
GeForce RTX 5060 in certain motherboards could experience blank screens
by
Alex5723
3 days, 4 hours ago -
MS Office 365 Home on MAC
by
MickIver
2 days, 22 hours ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
3 days, 18 hours ago -
Flash Drive Eject Error for Still In Use
by
J9438
13 hours, 3 minutes ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
4 days, 13 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
4 days, 13 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
3 days, 16 hours ago -
Migrate off MS365 to Apple Products
by
dmt_3904
3 days, 17 hours ago -
Login screen icon
by
CWBillow
3 days, 7 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.