Copy Random Password to cell

farhad

New member
Joined
Jul 17, 2018
Messages
17
Reaction score
0
Points
1
Excel Version(s)
2013

Attachments

  • Zoom Meeting Schedule.xlsm
    56.1 KB · Views: 15
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
 
Hi Nos

I tried your suggestion and does seems to work. When I try macro it does nothing
 
My suggestion is a macro so I have no idea what you're doing.
 
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
 
Hi

More columns were added.
 
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.
 
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.
 
Back
Top