PDA

View Full Version : [SOLVED:] insert auto serial number in user form



AhmedMatboly
09-13-2022, 05:49 AM
hi there ,
i have excel sheet which have serial number for the data in column a and i want the text1"textbox"to have default value which is last value in column a +1
pls review my code which i am sure its so bad coz i am newbie and thnx in advance ..

Text1.Value = Cells(Column, "a").End(x1up).cell.Value + 1

SamT
09-14-2022, 06:24 AM
Private Sub UserForm_Initialize()
Dim NewSerno As Long

NewSerno = [Sheet].Cells(Rows.Count, "A").End(xlUp).Value + 1
[Sheet].Cells(Rows.Count, "A").End(xlUp.Offset(1) = NewSerno
Text1.Value = NewSerno
End Sub

AhmedMatboly
09-17-2022, 04:25 AM
Private Sub UserForm_Initialize()
Dim NewSerno As Long

NewSerno = [Sheet].Cells(Rows.Count, "A").End(xlUp).Value + 1
[Sheet].Cells(Rows.Count, "A").End(xlUp.Offset(1) = NewSerno
Text1.Value = NewSerno
End Sub
Thanks sir for your help i really appreciate it