I have a very large work request data set that I need to clean up. The data set has some consistent elements there are a series of numbers that are a set length this is changes about about half way through the data set but the change is predictable. One issue with the data set is that there are multiple deliminator is some places, sometimes no deliminator, sometimes text in front etc. I pulled a sample of the variables that I am dealing with and separated them manually to show the desired result.
As you can see there are a few predictable variables and some that are user input errors.Notice that in some cases the numbers have a single character behind the 7 digit work request number most of the time separated by a "." but sometimes no separation as in A8 and A9. Sometime there are deliminator, "/" or "space", or "," but this isn't consistent. I am currently working with a VBA that manages to strip the numbers for some but fails when it encounters no numbers or extra numbers. Eventual the work request numbers were changed to add the R00 this is the "new" number and over half of the data uses this in some form.
The VBA that I am using:
Option ExplicitPublic Function Strip(ByVal x As String, LeaveNums As Boolean) As VariantDim y As String, z As String, n As Long For n = 1 To Len(x) y = Mid(x, n, 1) If LeaveNums = False Then If y Like "[A-Za-z ]" Then z = z & y 'False keeps Letters and spaces only Else If y Like "[0-9. ]" Then z = z & y 'True keeps Numbers and decimal points End If Next nStrip = Trim(z)End Function=NUMBERVALUE(Strip(A1,TRUE)) =Strip(A1,FALSE)This works in some places but not others. It also doesn't separate out C and D respectively. The most important issue is stripping out the work request number as seen in B.