I have a small userform with textboxes and comboboxes in it. There is a summary table in worksheet. What i want is, when the userform is initialised, the code should go through the table column (voucher # i.e. 2) and generate the next number in the textbox2.
Here is my code:
Private Sub UserForm_Initialize()
Dim NextNum As Long, prefix As String
Dim i As Long
prefix = "BPV/"
NextNum = Application.WorksheetFunction.Max(Sheet1.UsedRange.Columns(2))
i = NextNum + 1
Me.TextBox2.Enabled = False
Me.TextBox2.Value = prefix & i
End Sub
When the userform runs, it doesnt calculate the next number in sequence. Kindly review and help me.
Thanks

Private Sub UserForm_Click()it works ok (when clicked). Don't know why is not working under Inicialize.