Hi JR,
JR said:
I have a list of barcode numbers, and I need to be able to remove the last
digit, if possible, with a macro.
I would go with the solution proposed by Dave Peterson, but if you need a
macro, try:
Sub TrimEleventhDigit()
Dim rng As Range
Dim rw As Long
Dim cell As Range
' // Amend each of the 4 following Const values
Const BCodeLen As Long = 11 '<<== CHANGE
Const Col As String = "A" '<<==
CHANGE
Const FirstRow As Long = 1 '<<== CHANGE
Const ShtName As String = "MyBCodeShtName" '<<==CHANGE
Application.ScreenUpdating = False
With Sheets(ShtName)
rw = .Cells(Rows.Count, Col).End(xlUp).Row
Set rng = .Range(.Cells(FirstRow, Col), .Cells(rw, "A"))
End With
For Each cell In rng.Cells
With cell
If IsNumeric(.Value) Then
If Len(.Value) = 11 Then
.Value = Left(.Value, BCodeLen - 1)
End If
End If
End With
Next cell
Application.ScreenUpdating = True
End Sub