Just what this has to do with keeping the first 6 characters in a cell, I don't know?
For Each cell In Range("M3", Range("M" & Rows.Count).End(xlUp))
cell.Value = Val(cell.Value)
cell.Offset(0, -7).NumberFormat = "0"
Next cell
However try this
Sub LotRemove()
Dim LastRow As Long
LastRow = Range("M" & Rows.Count).End(xlUp).Row
' Temporary helper Column
Range("IV2").Formula = "=Trim(Left(M2,6))"
Range("IV2:IV" & LastRow).FillDown
Range("IV2:IV" & LastRow).Copy
' Destination Column
Range("M2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
' Clear Temporary helper Column
Range("IV2:IV" & LastRow).Clear
Range("M2:M" & LastRow).Offset(0, -7).NumberFormat = "0"
LastRow = Range("L" & Rows.Count).End(xlUp).Row
Range("E1:E" & LastRow).AutoFilter Field:=1, Criteria1:="="
Range("E2:E" & LastRow).Replace What:="", Replacement:="'", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("E1:E" & LastRow).AutoFilter
Range("H1:H" & LastRow).AutoFilter Field:=1, Criteria1:="="
Range("H2:H" & LastRow).Replace What:="", Replacement:="'", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("H1:H" & LastRow).AutoFilter
End Sub
1/. What purpose does filling blank cells with an apostrophe serve? I'm curious.
2/. There is nothing in this code, as can clearly be seen, that could not been done without a macro,
3/. For one-offs you should consider using Excel as it comes straight out of the box.
Hope this helps.
Bookmarks