Random Number Generator Macro

  • I've been spending the past two months reading and searching your site for what I'm looking for, but no luck.
    What I'm trying to do is as follows:
    Sheet 1
    A1 through A6 has STR, DEX, CON, INT, WIS and CHA. B1 through B6 is waiting for results from sheet 2.


    Sheet 2
    A1 is data validation of d4, d6, d8, d10, d12, d20 and d100. A2 through A7 are currently Rand formulae triggered by A1 with B1 adding number of dice (minimum 1) and B2 a modifier value add to the rolled result. D2 through D7 are data validation modifiers of -10 to +10 (0 included). E2 through E7 is the result of A2+C2. The Rand works fine, but every time data is changed Rand recalculates. I'm hoping for a macro executed by a button to generate six random numbers based on the chosen die value of A1 ranging from 1-4 to 1-100. The die roll can never be below 1 and no higher than the chosen die. I then want to transfer the result from E? To sheet 1 B1 to B6 matching its appropriate atribute. I named them Char01_STR, etc on sheet 1 A1 to A6.


    I'm hoping ya'll can help and that I followed your rules for posting adiquately.


    Thanks

  • Re: macro for auto-roller based of selected die value


    With all the different variables, and if it involves VBA, its a lots easy to help if you post an example of the worksheet layout.

  • Re: macro for auto-roller based of selected die value


    Quote from Reafidy

    With all the different variables, and if it involves VBA, its a lots easy to help if you post an example of the worksheet layout.



    I guess it'll have to wait till tomorrow then. I unfortunately do not have internet at home and am using your forum from my phone. Tomorrow I will supply an example when I get to the library in the evening.

  • Re: Random Number Generator Macro


    okay, i was hoping that above was going to be detailed enough, but alass, i assumed to much. it's actually nice to see this site from a comuter view. it's really nicely laid out.


    down to business!


    I found RANDBETWEEN on the forum and how to get on on my computer and how to use it. it's much cleaner. i'm including an example of what i'm trying to do. i hope i explained enough what i'm looking to do in the file.

  • Re: Random Number Generator Macro


    Good morning. I woke up this morning realizing that RANDBETWEEN is not gonna work as easily as I like. If I move my file to another computer it needs to have that toolpack 'add-in' installed on that machine. Is there code to do the same result? If so then all I need is code to 'roll the dice' and code to transfer from sheet one to sheet two.

  • Re: Random Number Generator Macro


    see this from the help files


    Quote


    To produce random integers in a given range, use this formula:


    Int((upperbound - lowerbound + 1) * Rnd + lowerbound)


    Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.

  • Re: Random Number Generator Macro


    Okay, I was reading on through this forum and finally found a post describing a similar delema. A reaponce suggested this person to, as one of two options, copy/paste special and that made me think...
    I tried creating a macro using copy/paste special value and this has given me the seporation I was looking for between Rand and result.
    Macro as follows:

    Code
    Sub RandomNumber()
       Range("A7:A12).Select
       Selection.Copy
       Range(D7:D12).Select
       Selection.PasteSpecial Paste:=xValues, Operation:=xNone, SkipBlanks:= _
             False, Transpose:=False
    End Sub


    Is there a way to get this same result without the marque showing on copy?


    I also tried doing the same for moving my resulting scores after modifying from sheet two to sheet one and found I'm only able to do this with copy/paste special link. Any other way and I'm told "This operation requires the merged cells to be identically sized". For as far as I can tell, they are.
    Macro as follows:


    This above macro works, but again I have the select marque when the macro executes every line that is copy. To top it off, when I click my button for this macro I get sheet flip-floping as the macro executes every copy/paste. I defonately don't like that.


    What can I do to eliminat the selection marque for each macro and prevent the sheet flip-flop?


    Doing this from my phone has been very tedious and my fingers are tired...


    Thanks for any advice I may receive in this. I'm still messin around to are what I can find.

  • Re: Random Number Generator Macro


    daamyour, Welcome to the forum. However, please read the rules and use code tags around VBA code. I have added them for you this time, but normally the post would be deleted.

  • Re: Random Number Generator Macro


    Quote from daamyour

    What can I do to eliminat the selection marque for each macro and prevent the sheet flip-flop?


    Try putting:


    Code
    Application.ScreenUpdating = False


    at the top of your macro


    and

    Code
    Application.ScreenUpdating = True


    at the end

  • Re: Random Number Generator Macro


    ByTheCringe2


    Sorry bout the tags. I wasn't thinking macros as code. I was thinking for VBA is code tags, but I guess VBA are similar or the same?


    JF


    Is this what you meant? I tried it how I think you ment but I still get flip-flop and marque. Which was your suggestion ment to resolve?


  • Re: Random Number Generator Macro


    Okay, I got Application.ScreenUpdating = False/True working and I know how I can kind of hide the selection marque unless there is somone that knows how to do what I'm trying differently? Now though, instead of the flip-flop I was getting,0im getting a flicker. Can this be cleaner?

  • Re: Random Number Generator Macro


    Thanks to ya'll for help wit this. I got what I was looking for and on to other things I need help in that I'll start in new threads.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!