Insert marker in text

vhobbs1

New Member
Joined
Jul 28, 2009
Messages
1
I need to insert a marker (like "/") between a zip code and an occupation in a text cell in order to separate the text into two cells. How can I devise a formula that will "find" the 5-digit zip code, then insert a marker after the zip? Help!

Before:
221 South Union # 1 Jackson MO 63755 Lutheran Pastor

After:
221 South Union # 1 Jackson MO 63755 / Lutheran Pastor
 
hiker95

No problem.:)

Mind you I think I just lucked out on this one - I've been trying to fully understand regular expressions for ages.

Only ever use/try to use them every now and again - normally when something comes up here.

But I've never been able to find a comprehensive guide to them.:eek:

So I don't know if what I've posted is fully reliable or robust, but it seems to work for the posted data.:)

Hi Norie,

I've seen them used here but always been a bit of a mystery to me. Came across this when I tried (and failed) to answer a post using them not long ago:

http://www.regular-expressions.info/index.html

I'm sure they make sense once you've got your head round the syntax but it's all Dutch to me at the moment.

Dom
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Dom

That's actually the site I was looking at earlier.:)

Seems better than some of the others I tried - even looked at Wikipedia.:eek:

But like you say it's all a bit Dutch, and I've also got a feeling that regular expessions aren't that 'regular' depending on what app/language you are using.:)
 
Upvote 0
Just tried another UDF.
Code:
Option Explicit
Function GetZip(rng As Range)
Dim RegEx As Object
Dim RegMatchCollection As Object
Dim n
    Set RegEx = CreateObject("vbscript.regexp")
    With RegEx
        .Global = True
        .Pattern = "([0-9]{5})"
    End With
    Set RegMatchCollection = RegEx.Execute(rng.Value)
    
    GetZip = RegMatchCollection(0)
    
End Function
I like it better because it appears to extract the zip code, assuming it's 5 numbers.

Oops, just did a little bit of a test - seems to pick up anything that starts with 5 numbers.:)
 
Upvote 0
Hiker95

I think I've looked at both those sites, but I've still not found anything comprehensive.:)

I'm probably missing something, or just can't be bothered to look through the links/sites properly.

Anyways, I'll be off to bed as soon as I remember the name of that guy who was in a late 70's film with cars and stuff.

Barry something...

Anyways, he seems to have popped up in Quincy ME as a dodgy doctor.:)
 
Upvote 0

Forum statistics

Threads
1,216,773
Messages
6,132,641
Members
449,739
Latest member
tinkdrummer

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top