Hello,
I am a VBA novice and was able to Google a bunch of simple commands that I combined into a single macro, but I cannot figure out what to use to do the last needed item. Can you please help?
I have a large report (up to 3k rows of data) with a unique serial number identifier in each row. Theoretically, each of these serial numbers should begin with C and end with eight trailing digits ("C12345678"), but sometimes they have two Cs at the beginning, or have a V instead of a C, or have seven or nine digits trailing, etc. Just keying errors. I want to remove all the text characters, regardless of case, regardless of placement in the string, so I'm just left with the numbers, in the same cells as before, and want to have that combined within the same macro (as the last step of the macro).
The rest of the macro I've put together is:
So I'm unmerging, adding a text header to one column, deleting the top dozen rows, deleting a LOT of empty columns, unwrapping text, autofitting what's left, moving column D to the left of column C, deleting any now-empty rows within the sheet and making the values in columns C and D positive instead of negative. This is what I'm left with after that:
Please let me know if more detail is needed.
I am a VBA novice and was able to Google a bunch of simple commands that I combined into a single macro, but I cannot figure out what to use to do the last needed item. Can you please help?
I have a large report (up to 3k rows of data) with a unique serial number identifier in each row. Theoretically, each of these serial numbers should begin with C and end with eight trailing digits ("C12345678"), but sometimes they have two Cs at the beginning, or have a V instead of a C, or have seven or nine digits trailing, etc. Just keying errors. I want to remove all the text characters, regardless of case, regardless of placement in the string, so I'm just left with the numbers, in the same cells as before, and want to have that combined within the same macro (as the last step of the macro).
The rest of the macro I've put together is:
VBA Code:
Sub LOR()
Range("AF:AF").UnMerge
Range("AR13").Value = "LBS"
Range("1:12").Delete
Range("A:A, C:C, D:D, E:E, F:F, G:G, H:H, J:J, K:K, L:L, M:M, N:N, O:O, P:P, Q:Q, R:R, S:S, T:T, U:U, V:V, W:W, X:X, Y:Y, Z:Z, AA:AA, AB:AB, AC:AC, AD:AD, AE:AE, AF:AF, AG:AG, AH:AH, AI:AI, AJ:AJ, AK:AK, AL:AL, AM:AM, AN:AN, AP:AP, AQ:AQ, AS:AS, AT:AT").Delete
Range("A:D").WrapText = False
Range("1:3000").EntireRow.AutoFit
Range("A:D").EntireColumn.AutoFit
Columns("D").Cut
Columns("C").Insert Shift:=xlToRight
Sheets("Sheet1").Select
Range("A2:A3000").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Dim cel As Range
For Each cel In Columns("C:D").SpecialCells(xlCellTypeConstants, 1)
cel.Value = Abs(cel)
Next
End Sub
So I'm unmerging, adding a text header to one column, deleting the top dozen rows, deleting a LOT of empty columns, unwrapping text, autofitting what's left, moving column D to the left of column C, deleting any now-empty rows within the sheet and making the values in columns C and D positive instead of negative. This is what I'm left with after that:
Please let me know if more detail is needed.