REGEX on Range of cells

gallen

Well-known Member
Joined
Jun 27, 2011
Messages
2,016
Hello,

I'm not new VBA but fairly green on regex.

An example of the cells is:

1004006088 ProductName 3.0MM 2X20LM

I need to find the "MM" and then all numeric characters to the left including the period. However sometimes the text may have an space between the numerics and the "MM" so I need to allow for this too

1004006088 ProductName 3.0 MM 2X20LM

Ultimately I need to extract the 3.0MM or 3.0 MM ONLY.

Reading a few tutorials has just ended up me getting more confused.

Any help would be appreciated
 
Hi,

If you want to have fun with a long formula :)

Ctrl+Shift+Enter NOT just Enter

=SUBSTITUTE(MID(A2,MATCH(TRUE,ISNUMBER(1*MID(A2,ROW($1:$10),1)),0),COUNT(1*MID(A2,ROW($1:$10),2))),RIGHT(MID(A2,MATCH(TRUE,ISNUMBER(1*MID(A2,ROW($1:$10),1)),0),COUNT(1*MID(A2,ROW($1:$10),2))),1),"")&" "&RIGHT(A2,(LEN(A2)-SEARCH("m*",A2,SEARCH("m*",A2,1)))-2)
 
Last edited:
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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