Private Sub CommandButton1_Click()
Sheets("Objednávky přeprav").Select
dd = Day(Now): mm = Month(Now): rr = Year(Now)
Columns("A:A").NumberFormat = "dd/mm/yy;@"
Columns("B:B").NumberFormat = "@"
pRadek = Application.WorksheetFunction.CountA(Range("a:a"))
Cells(pRadek + 1, "A") = Now
On Error Resume Next
If Month(Cells(pRadek, "A")) < mm Then
poradi = 1: GoTo px
End If
If pRadek = 1 Then
poradi = 1
Else
poradi = CDbl(Right(Cells(pRadek, "B"), 4)) + 1
End If
px:
On Error GoTo 0
poradiTXT = Format(Str(poradi), "0000")
rokTXT = Format(Str(rr), "0000")
mesTXT = Format(Str(mm), "00")
denTXT = Format(Str(dd), "00")
Cells(pRadek + 1, "B") = rokTXT & mesTXT & denTXT & poradiTXT
End Subcitovat