Cleaning up serial numbers, HELP!!!

rob_andy

New Member
Joined
Mar 12, 2003
Messages
33
I need to convert a column of serial numbers so I can link two tables.
In one table they are stored as follows:
005-666 or D0001 or L1234 these can all vary in length

In the table I want to like to they are stored as follows

005-666@ Blah Blah
D0001-01-03
D0001/06/02
Machine (no.1) D0001-02
L1234 Bugger

And a number of other different formats. I've done some simple filtering as follows:

Set dbs = CurrentDb

Set rst = dbs.OpenRecordset("SELECT rDawMachineLocal.* FROM rDawMachineLocal")
With rst
.MoveFirst
Do Until .EOF
dawserial = Trim(![ceq_serial])
If Not dawserial = "" Then

LeftTrimPosition = InStr(1, ![ceq_serial], "/")

Select Case LeftTrimPosition
Case Is > 7
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
Case 0
LeftTrimPosition = InStr(1, ![ceq_serial], " ")
End Select
.Edit
If LeftTrimPosition = 0 Then
![Serial] = dawserial
Else
![Serial] = Left(dawserial, LeftTrimPosition - 1)
End If
.Update
.MoveNext
LeftTrimPosition = 0
Else
.Edit
![Serial] = "Not Available"
.Update
.MoveNext
LeftTrimPosition = 0
End If
Loop
End With
dbs.Close

But this only captures the simple variations, does anybody have any tips or examples of how I can filter the D****** or the 005-*** perfectly? Thanks in advance. R
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,221,572
Messages
6,160,575
Members
451,656
Latest member
SBulinski1975

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