Sub BatchMaker()
Dim FstVal, LstVal As String
Dim FstRow, LstRow As Integer
Range("A2").Select
Do Until IsEmpty(ActiveCell)
'End Batch
Do Until IsEmpty(ActiveCell)
If ActiveCell.Offset(1, 0).Value = ActiveCell.Value + 1 Then
ActiveCell.Offset(1, 0).Select
Else
Exit Do
End If
Loop
LstVal = ActiveCell.Value
LstRow = ActiveCell.Row
'Start Batch
Do Until IsEmpty(ActiveCell)
If ActiveCell.Offset(-1, 0).Value = ActiveCell.Value - 1 Then
ActiveCell.Offset(-1, 0).Select
Else
Exit Do
End If
Loop
FstVal = ActiveCell.Value
FstRow = ActiveCell.Row
'Write batch
If FstRow = LstRow Then
Range("B" & FstRow).Value = FstVal
Else
Range("B" & FstRow).Value = FstVal & "-" & LstVal
End If
Range("A" & LstRow + 1).Select
Loop
MsgBox "Macro completed", vbInformation, ""
End Sub