• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unique Auto Number Required

I have an excel vba user from .I want auto generated unique number in one of the text box on my user form . I want that when i click the save button , the number transfer my sheet.For this i write the following code but it gives the number again and again.I require the unique no.Please some one help me to correct my code to get unique no.
Code:
Dim Low As Long
Dim High As Long
Dim r As Long
Low = 1
High = 9999
r = Int((High - Low + 1) * Rnd() + Low)

TextBox9.Text = r
 
What's the purpose of unique number? Is it just for identification or is it used for some other calculation etc?
 
will u explain a little?I want to transfer this no 3 sheets at the same time from one text box.

▬▬▬▬▬▬▬▬▬ Mod edit : thread moved to appropriate forum !
 
Upload a sample, it would help in seeing your exact requirement.

But to explain, if you need unique number associated to each employee being tracked. Start with 1, and increment by 1.

So, logic would be. Row# of cell being updated - offset value.
 
yes you are right but it is possible only in excel column i want a unique no in text box and transfer the same no into three different worksheet.
 
So you can add something like below to regular module...

Code:
Sub GenerateID()
SalaryForm.TextBox9.Value = Sheets(" EmpData").Cells(Rows.Count, 3).End(xlUp).Row

End Sub

And call it on UserForm initialize event to populate Emoloyee ID text box.
Code:
Private Sub UserForm_Initialize()
Call GenerateID
End Sub
 

Attachments

  • Salary1 - .xlsm
    37.6 KB · Views: 10
Back
Top