Results 1 to 3 of 3

Function inside a button to randomly generate number?

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2014
    Location
    London
    MS-Off Ver
    XP
    Posts
    6

    Function inside a button to randomly generate number?

    Hi

    I am trying to put a function into a button.

    The function is

    Function RandomSelection(aRng As Range)
    'Update20131113
    Dim index As Integer
    Randomize
    index = Int(aRng.Count * Rnd + 1)
    RandomSelection = aRng.Cells(index).Value
    End Function
    Then I added an array (spin_range) that cover four cells with values 1, 2, 3, 4.

    Then I added =randomselection(spin_range) which randomly generates either 1, 2, 3 or 4.

    Now I want to add a button to generate this in a cell so I don't have to click into the formula and refresh.

    How do I do this?

    Many thanks
    Last edited by Fotis1991; 09-16-2014 at 05:04 AM. Reason: Pls next time use code tags around your codes as per forum rules.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Simple macro to randomly generate 0 or 1
    By mattdaviddesign in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2013, 08:32 PM
  2. Replies: 0
    Last Post: 11-02-2012, 07:57 PM
  3. VBA Button to generate a number which does not duplicate ~ criteria based
    By opattison in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2012, 09:38 AM
  4. generate a random number and use if function to generate new data
    By Dogdoc1142 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2006, 10:50 PM
  5. [SOLVED] Generate column of 1's and 0's randomly
    By Ian Engelbrecht in forum Excel General
    Replies: 6
    Last Post: 04-01-2006, 09:52 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1