Because I use VBA for just about everything, 
my approach is a bit more involved...

What I would suggest is to create a Worksheet_Change event:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim I, Col_Name, Col_Pin
    Col_Name = 1 'Column to monitor for content
    Col_Pin = 2  'Column to show PIN
    For I = 1 To Target.Count  '(necessary for adding multiple lines)
        If (Target(I).Column = Col_Name) And (Target(I).Value <> "") Then
            'Check to see if a change is made to a monitored column 
            'and it is not empty
            If (Cells(Target(I).Row, Col_Pin) = "") Then  ' Is PIN cell blank?  
               'changes cause the event to run itself, so turn off
                Application.EnableEvents = False                  
                 Cells(Target(I).Row, Col_Pin) = _ 
                 Application.WorksheetFunction.RandBetween(1000, 9999)
                Application.EnableEvents = True
            End If
        End If
    Next I
End Sub

Do you know how to add it to the sheet macro module?

let me know...

Paul




________________________________
From: Grunta <grun...@gmail.com>
To: MS EXCEL AND VBA MACROS <excel-macros@googlegroups.com>
Sent: Tuesday, April 28, 2009 7:21:28 PM
Subject: $$Excel-Macros$$ Help with creating a unique set of numbers


Hello

I would like a solution regard to excel formulas / VBA scripting.

The purpose is to assist in generatating unique PIN numbers for users
on our phone system..

The numbers generated need to be a number between 1000 & 9999...

The basic formula I have used (=RANDBETWEEN(1000,9999)) does it
initially, but if the formula gets extended or a row gets deleted the
numbers are regenerated....

The numbers need to remain how they are at the initial time of running
the formula..

Any ideas? – I guess there needs to be some fault tolerances involved,
but for the life of me I would know what they are....

Kind Regards,

Grant


--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to