Automatically filling in a unique quote number on a form

wattsup

New Member
Joined
Jul 14, 2011
Messages
8
I have a form that is used to input information into a database, and as part of that form there is a quote number entry that must be filled in with a unique six digit number. These numbers are basically six digit numbers that go up in 10s, i.e.

If the last used number was 110010 then the next number will be 110020.

What I would like to do is when the form initialises that the next number is automatically placed in the quote number textbox. I have done a similar thing for todays date but I am new to VBA and am finding this quite tricky. Anybody have any ideas?

Thank you in advance

wattsup
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Where is the location of the last number entered?

The macro would simply need to know where to look for the last entered number, then add 10 to it right?

Example: If the entries were stored on Sheet 3, and the Qoute Number goes in Col A, then you could add this to the UserForm Initialize Event:

Code:
Dim QteNumber as Integer
 
QteNumber = Worksheets("Sheet 3").Range("A1").End(xlDown).Value
QteNumber = QteNumber + 10
UserForm1.TxtBox1.Value = QteNumber
 
Upvote 0
The problem is it won't always be the last numbered entered and the database will often be reordered as well. Is there a way I could find the max of the range of numbers (which I have named as QuoteNumberList) and then add 10 to it?
 
Upvote 0
Sure use this:


Dim i As Long

i = Application.WorksheetFunction.Max(Sheet1.Range("QteList"))

'Where Sheet1.Range("QteList") = your Defined Name & Sheet it resides on.

i = i + 10
UserForm1.TxtBox1.Value = i
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,775
Members
452,942
Latest member
VijayNewtoExcel

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