New Text Document
New Text Document
Dim ws As Worksheet
Dim lastRow As Long
Dim newDiaryNo As Long
Dim lastDiaryNo As Variant
' ?? Diary No. will always start from 1 if no previous records exist
If IsNumeric(lastDiaryNo) And lastRow > 1 Then
newDiaryNo = CLng(lastDiaryNo) + 1 ' Convert to Long before incrementing
Else
newDiaryNo = 1 ' ?? Start from 1 instead of 1001
End If
' ? Update the Diary No. label with "Diary No. XXXX"
lbldiaryno.Caption = "Diary No. " & newDiaryNo