Unique Number

  • Thread starter Thread starter Noctos
  • Start date Start date
N

Noctos

Hi, i am creating a database where user's enter the details and at th
end of data entry they are given a unique number. Now i want thi
unqiue number to be one plus the previous user's number. The firs
value will be 1000.

So first person has ID 1000 then nwhen the macro is run for the secon
person the second person will have ID 1001.

Has anyone got any idea how i can do this
 
Hi

You don't tell us how you set up your database
But if the column with the Id numbers is column A and sorted
You can use this

Sub test()
Dim num As Long
num = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Value + 1
MsgBox num
End Sub
 
Another method would be

Dim num as Long
num = application.MAX(worksheets("Sheet1").Range("A:A") +1

--
Regards,
Tom Ogilvy

Ron de Bruin said:
Hi

You don't tell us how you set up your database
But if the column with the Id numbers is column A and sorted
You can use this

Sub test()
Dim num As Long
num = Sheets("sheet1").Range("A" & Rows.Count).End(xlUp).Value + 1
MsgBox num
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top