Ok no problem Replace the code with this. It remove any thing thats not 0-9. So It Could Be N1V101A output would be 1101
Sub abc()
Dim ws As Worksheet
Dim LastRow As Long, ptr As Long, iCol As Long
Set ws = ActiveSheet
LastRow = ws.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For ptr = 2 To LastRow Step 2
For iCol = 2 To 5
With ws.Cells(ptr, iCol)
If Trim(.Value) <> vbNullString Then
If Not IsNumeric(Trim(.Value)) Then
.Value = RemoveNonNumeric(.Value)
.Value = .Value - ws.Cells(ptr + 1, iCol)
ws.Cells(ptr + 1, iCol) = ""
End If
End If
End With
Next iCol, ptr
Set ws = Nothing
End Sub
Public Function RemoveNonNumeric(sNumberToClean As String) As String
Const NUMERIC_CHARS = "0123456789"
Dim lThisChar As Long
Dim sResult As String
For lThisChar = 1 To Len(sNumberToClean)
If InStr(1, NUMERIC_CHARS, Mid$(sNumberToClean, lThisChar, 1)) > 0 Then
'Found a numeric character
sResult = sResult + Mid$(sNumberToClean, lThisChar, 1)
End If
Next
'Return the result
RemoveNonNumeric = sResult
End Function
Bookmarks