Excel Pattern Matching

MartinAustin

New Member
Joined
Mar 31, 2006
Messages
10
Hello everyone --

I have a deadline on monday for a project that seems as though regular expressions would fit the bill (though I am willing to try anything at this point).

The issue is cleaning a certain column of data of erroneous characters. The column represents an inbound shipments PO number, and can only be comprised of 7 numerical characters in a row. Here are some examples of what we get in this field:

7777-1234567-99
77,1234567-00

Etc, etc. The 1234567 is the valid PO number, and all I want to do is find the first occurence of 7 numerical characters in a row, store it in a variable, erase the current cell value, and place the 7 digit PO number back into the same field.

Ones that do not match should be copied into another sheet in Excel (which I can do no problem), but I'm having a hell of a time figuring this one out.

Can someone out there get me started? Thanks, and God Bless!

[edit: updated title since it doesn't have to be a regular expression solution, as long as it works! :eek:)]
 
Actually, I have one follow up question. What I'd like to do is move the clean POs to another sheet, and the dirty POs to their own sheet as well. I can do this, though it is quite a roundabout and ungainly method.

Is there an easy method to do this?

Thanks!
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,215,982
Messages
6,128,100
Members
449,420
Latest member
AussieHobbo

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