Auto number textbox value when worksheet is initialized.

Christiaan Viljoen

New Member
Joined
Oct 2, 2014
Messages
11
Hey guys.... I've got a userform 2 that is used to input values and data into a invoice that has been created on a worksheet named invoice. All data entered on this userform will also be saved on a worksheet named statements for filtering later on... What I need is the invoice number to be updated automatically when the userform is opened. I. Would like to retreive this number from the statements worksheet like column a will contain all invoice numbers in order. When a invoice is saved it needs to save it with the number in next open row and then retrieve that number 1 next time the userform opens. Hope it makes sense... Thanks a lot. I now realize I said worsheet on the title instead of userform. Sorry for that.
 
Last edited:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hey andrew. Nothing happens... I'm not sure where to enter the coding. If I put it under userform initialize it gives me run-time error '9': subscript out of range
 
Upvote 0
I changed it to sheet6... It now shows
Private sub userform_initialize()
Dim n as integer
Do
N=n+1
Combobox1.additem sheets(n).name
Loop until n = worksheets.count
Textbox1.text=worksheetfunctions.max(worksheets("sheet6").columns(1))+1
End sub
 
Upvote 0
Yes I do.. That's where I want to get the invoice number from.... It has values in a1 to a6 so my plan is to take a6 value +1 for the invoice number and when the invoice save it puts the data in next open row witch will be a7 then next invoice it need to call a7 +1 and so on
 
Last edited:
Upvote 0
You can't have a worksheet named sheet6 if you get a subscript error. The code uses the Name (what's on the sheet's tab) not the CodeName.
 
Upvote 0

Forum statistics

Threads
1,214,897
Messages
6,122,141
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top