simplicityq88
New Member
- Joined
- Mar 21, 2011
- Messages
- 11
Dear friends - excel professionals and excel learners,
I've stumbled up a problem in one of my tasks. Let me try to explain what I actually need.
Well like in databases when you enter a new field the set unique identifier put a random number, the same thing I'm trying to reflect here on my excel project.
I would like to imediatelly say that RAND functions can't be of much help since they generate new ones every time, I need a number that will generate and stay there all the time.
Example:
................... 9 digit ....................... 15 digit ..................... 8 digit
Name________Number 1____________Number 2_____________Number 3
Test _________123456789__________ 1.....15 ______________87654321
___________________________________________________
WHEN I TYPE IN THE NEW NAME so: IF Ax IS NOT BLANK GENERATE UNIQUE NUMBER for Every of these digits.
I've found some scripts that check if the next entered numbers are unique and gives a checkbox but I have not found a solution like this one.
Thank you friends in advanced!
I've stumbled up a problem in one of my tasks. Let me try to explain what I actually need.
Well like in databases when you enter a new field the set unique identifier put a random number, the same thing I'm trying to reflect here on my excel project.
I would like to imediatelly say that RAND functions can't be of much help since they generate new ones every time, I need a number that will generate and stay there all the time.
Example:
................... 9 digit ....................... 15 digit ..................... 8 digit
Name________Number 1____________Number 2_____________Number 3
Test _________123456789__________ 1.....15 ______________87654321
___________________________________________________
WHEN I TYPE IN THE NEW NAME so: IF Ax IS NOT BLANK GENERATE UNIQUE NUMBER for Every of these digits.
I've found some scripts that check if the next entered numbers are unique and gives a checkbox but I have not found a solution like this one.
Thank you friends in advanced!
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range, Dn As Range, n As Long
Application.EnableEvents = False
If Not Intersect(Target, Columns("Q:Q")) Is Nothing Then
Set Rng = Range(Cells(1, Target.Column), Cells(Rows.Count & Target.Column).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not .Exists(Dn.Value) Then
.Add Dn.Value, ""
Else
MsgBox "The value " & Dn.Value & " Is a Duplicate"
Dn.Value = ""
End If
Next
End With
End If
Application.EnableEvents = True
End Sub
Last edited: