UserForm

pan_kaj

Board Regular
Joined
Dec 28, 2004
Messages
80
I have a userform that I use to enter data for Calls to fix faults.

Once the form is filled and submit is pressed, I want a Call reference number to be generated. This call reference number is a 6 digit number starting 100001 onwards.

Once generated, it should store this number in the database. (i hv a column named Call_Ref_No for it)

Can someone please help?

Cheers
PJ
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
After you have submitted the data, add this code with the correct column

Code:
CallRefNum = Range("A" & Range("a65536").End(xlUp).Row).Value + 1

Range("A" & Range("a65536").End(xlUp).Row).Offset(1, 0).Value = CallRefNum
 
Upvote 0
How do i get a msg box to appear which displays the following message:

Your call reference number is XXXXXX. Please note this for future reference.

XXXXXX being the number allocated by code given.
 
Upvote 0
If you're using Milo's code you can just use:

MsgBox "Your call reference number is " & CallRefNum & ". Please note this for future reference."

HTH,
 
Upvote 0
Milo,

THe code provided stores the last value it passes. I want the starting value for CallRefno to be 100001 and when it allocates the next callrefno for a new call, it should check column R and assign the callrefno as 1 more than that greatest number it finds.

Can you help?
 
Upvote 0
the easiest way would be to prepopulate the first reference number in the appropriate column with 100000. Then the code will add 1 to that for the first entry.
 
Upvote 0
I tried that Milo, but the code somehow resets itself, and doesnt check the column! so if i shut the file down and restart the excel workbook, it starts again from 1. confusing........
 
Upvote 0
in what sheet and column are you storing the numbers? If they are on a different sheet, that is probably the problem.

Change Column and sheet names as applicable.

Code:
CallRefNum = Sheets("[B]Sheet2[/B]").Range("[B]A[/B]" & Sheets("[B]Sheet2[/B]").Range("[B]a[/B]65536").End(xlUp).Row).Value + 1

    
Sheets("[B]Sheet2[/B]").Range("[B]A[/B]" & Range("[B]a[/B]65536").End(xlUp).Row).Offset(1, 0).Value = CallRefNum
 
Upvote 0

Forum statistics

Threads
1,214,377
Messages
6,119,182
Members
448,872
Latest member
lcaw

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