Sub in_bg()
Dim tu, den, j, tong As Long
Dim ok As String
Worksheets("Format").Range("D16:F60000").ClearContents
ok = Worksheets("Format").Cells(2, 2).Value 'Doc gia tri dang text
tu = Val(ok) 'Lay gia tri dang so cua Text
den = Worksheets("Format").Cells(2, 10).Value
tong = tu + den
j = 16
For i = tu To tong - 1
If i <= 9 And i >= 1 Then
m = CStr("000000") & CStr(i)
End If
If i <= 99 And i >= 10 Then
m = CStr("00000") & CStr(i)
End If
If i <= 999 And i >= 100 Then
m = CStr("0000") & CStr(i)
End If
If i <= 9999 And i >= 1000 Then
m = CStr("000") & CStr(i)
End If
If i <= 99999 And i >= 10000 Then
m = CStr("00") & CStr(i)
End If
If i <= 999999 And i >= 100000 Then
m = CStr("0") & CStr(i)
End If
Worksheets("Format").Cells(j, 6).Value = m
Worksheets("Format").Cells(j, 5).Value = i
j = j + 1
Next i
End Sub