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
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Milo_Minderbinder

Well-known Member
Joined
Mar 2, 2006
Messages
548
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
 

pan_kaj

Board Regular
Joined
Dec 28, 2004
Messages
80
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.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
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,
 

pan_kaj

Board Regular
Joined
Dec 28, 2004
Messages
80

ADVERTISEMENT

thanks! works just fine!
 

pan_kaj

Board Regular
Joined
Dec 28, 2004
Messages
80
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?
 

Milo_Minderbinder

Well-known Member
Joined
Mar 2, 2006
Messages
548

ADVERTISEMENT

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.
 

pan_kaj

Board Regular
Joined
Dec 28, 2004
Messages
80
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........
 

Milo_Minderbinder

Well-known Member
Joined
Mar 2, 2006
Messages
548
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,215
Messages
5,594,883
Members
413,947
Latest member
gizmolucy

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
Top