Results 1 to 9 of 9

Thread: Copy Random Password to cell

  1. #1
    Seeker farhad's Avatar
    Join Date
    Jul 2018
    Posts
    15
    Articles
    0
    Excel Version
    2013

    Copy Random Password to cell



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Good Day

    I generated random numbers in Sheet2

    Sheet1 is a schedule of Meeting requests with Meeting number and Meeting Password

    I would like the password from Sheet2 to copy into Sheet1 without any duplicates.

    I have attached my Worksheet for clarity

    This has been posted already on https://www.excelforum.com/excel-pro...her-sheet.html

    Thanks
    Attached Files Attached Files

  2. #2
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    768
    Articles
    0
    Excel Version
    Excel 2010 64bit
    Maybe
    Code:
    Sub passpop()
        Dim lr As Long, n As Long
        Dim rng As Range, cel As Range, pwd As Range
    With Sheets("Sheet1")
        Set rng = .Range("E5", .Range("E" & .Rows.Count).End(xlUp))
    End With
    
    For Each cel In rng
        If cel.Offset(, 1) = "" Then
            With Sheets("Sheet2")
                lr = .Range("A" & .Rows.Count).End(xlUp).Row
                n = Application.WorksheetFunction.RandBetween(2, lr)
                Set pwd = .Range("A" & n)
                cel.Offset(, 1) = pwd.Value
                'move pwd to used list
                .Range("B" & .Rows.Count).End(xlUp).Offset(1).Value = pwd.Value
                pwd.Delete Shift:=xlUp
            End With
        End If
    Next cel
    End Sub

  3. #3
    Seeker farhad's Avatar
    Join Date
    Jul 2018
    Posts
    15
    Articles
    0
    Excel Version
    2013
    Hi Nos

    I tried your suggestion and does seems to work. When I try macro it does nothing

  4. #4
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    768
    Articles
    0
    Excel Version
    Excel 2010 64bit
    My suggestion is a macro so I have no idea what you're doing.

  5. #5
    Seeker farhad's Avatar
    Join Date
    Jul 2018
    Posts
    15
    Articles
    0
    Excel Version
    2013
    Hi
    This is the Macro I am using

    Code:
    Sub passpop()
        Dim lr As Long, n As Long
        Dim rng As Range, cel As Range, pwd As Range
    With Sheets("Sheet1")
        Set rng = .Range("I2", .Range("I" & .Rows.Count).End(xlUp))
    End With
    For Each cel In rng
        If cel.Offset(, 1) = "" Then
            With Sheets("Sheet2")
                lr = .Range("A" & .Rows.Count).End(xlUp).Row
                n = Application.WorksheetFunction.RandBetween(2, lr)
                Set pwd = .Range("A" & n)
                cel.Offset(, 1) = pwd.Value
                'move pwd to used list
                .Range("B" & .Rows.Count).End(xlUp).Offset(1).Value = pwd.Value
                pwd.Delete Shift:=xlUp
            End With
        End If
    Next cel
    End Sub

  6. #6
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    768
    Articles
    0
    Excel Version
    Excel 2010 64bit
    Why did you use column I ?

  7. #7
    Seeker farhad's Avatar
    Join Date
    Jul 2018
    Posts
    15
    Articles
    0
    Excel Version
    2013
    Hi

    More columns were added.

  8. #8
    Magician NoS's Avatar
    Join Date
    Jan 2013
    Location
    British Columbia
    Posts
    768
    Articles
    0
    Excel Version
    Excel 2010 64bit
    The suggested macro works with the file you attached.
    Apparently that's no longer what you're working with.
    I have no intention of guessing what you've now got.

  9. #9
    Administrator Pecoflyer's Avatar
    Join Date
    Oct 2011
    Location
    Brussels Belgium
    Posts
    1,663
    Articles
    0
    Excel Version
    2010 on Xubuntu
    Please,do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to ALL cross-posts.

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question

    Do not post any further responses in this thread until a link has been provided to these cross posts.
    Thank you Ken for this secure forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •