rnd

  1. kelly mort

    Use same value for a variable in a sub

    I have this function to randomly generate certain numbers. Then I am calling for its verification with another Sub. And display an alert. Then I found out that if there is a match, instead of the alert showing me the value for the match, it goes on to generate a new set of numbers from the...
  2. H

    VBA List Data

    Hi all, I have a list of data: Apple 580 Pear 245 Orange 867 Cherry 870 etc. What I want to do is split my inventory between 5 locations randomly, but will only ever total the total inventory and then have VBA print the array so that it's like the following: Apple 156 Apple 142 Apple 52...
  3. S

    Random number generator - vba

    I have found code online to generate a random number using VBA (on click of button) How do I get it to display a certain cell (H5) rather than in a msgbx? Sub random_num() 'Initialize the random number generator '=> Randomize : add this before you call the Rnd function to obtain...
  4. Trevor3007

    run code from another worksheet but same workbook

    good evening, I use this code:- Sub Gencode() ActiveSheet.Unprotect Static IsRandomized As Boolean Dim i As Integer, PW1 As String Dim cell As Range, PW As String If Not IsRandomized Then Randomize: IsRandomized = True For Each cell In Range("b3:b199")...
  5. F

    Modify - Generate mixed random alphanumeric code

    I came across below mentioned code which I liked, I need help in modifying this code. Is it possible to do so. If yes, I would like to see the generated output with mixed characters and colan punctuation between 2 characters (i.e. F2:3R:87:0T:58) . Note I tried generating a few, I could not...
  6. J

    Type Mismatch Error

    Hi, I am getting a Type Mismatch Error in the following code: Sub z() Dim u1 As Double, u2 As Double, m As Double, s As Double, i As Long Dim z(1 To 2) As Double m = 0 s = 1 For i = 1 To 100 u1 = Rnd() u2 = Rnd() z(1) = Sqr(-2 * Log(u2)) * Cos(2 * Application.WorksheetFunction.pi *...
  7. A

    Generate list of random numbers, using same starting seed

    I have inherited some VBA code in Excel 2016 - when the code is run, 500 users are input one by one, and a random number assigned to each one. As far as I understand, the code uses Randomize and Rnd (-1) to set the same starting seed each time, so that every time 500 users are input the same...
  8. M

    application transpose large array

    hi, i want to take an array and transpose it but am having issues. the problem appears to be the size of the array, does anyone know a fix? Sub stochastic() 'commutation functions Dim surv(1 To 100000) As Double Dim survv(1 To 100) As Double Dim i As Long, j As Long For i = 1 To 10000...
  9. Trevor3007

    run additional code in vb & yes/no

    Hi, I have this code that creates a random a password into a range:- Sub autocode() Static IsRandomized As Boolean Dim i As Integer, PW1 As String Dim cell As Range, PW As String If Not IsRandomized Then Randomize: IsRandomized = True For Each cell In...
  10. C

    Built in Rnd Function repeats after workbook closes.

    Hello, This is my first post, so I apologize in advanced for any errors or novice interactions. I have noticed that the Rnd Function repeats exactly the same pattern each time I close the workbook. I am running a dice macro for a board game. It is turn base for 7 players, after each roll the...
  11. B

    Evaluate Cell based on Number format VBA

    Hi, I'm trying to insert a random number into the unprotected cells on a worksheet depending on the type of number formatting in the cell. There are 4 basic cases: Number formatted as percent Number Formated general with no decimal places Number formatted general with two decimal places...
  12. J

    Syntax question - use of parentheses in rnd and randomize

    Hi there: Here goes a newbie's question. I was playing around with rnd function and randomize statement and noticed that seed values may be entered without the parentheses. I was wondering why such behavior is possible since my understanding was that any paramenters (for functions, at...

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top