+ Reply to Thread
Results 1 to 2 of 2

Command button to run calculation function

  1. #1
    Fleone
    Guest

    Command button to run calculation function

    I would like to know how to run the Calculate function until a match between
    two cells occurs.
    With the help of Ikaabod, Niek and Gary's Student I created a series of
    randomly generated numbers. I have a completely separate cell that is also
    running the RANDBETWEEN function. I would like to have a button that when
    pushed runs the Calculate command on the worksheet until a match occurs
    between two cells that are generating random numbers.
    Is this possible?
    Thanks!

  2. #2
    Fleone
    Guest

    RE: Command button to run calculation function

    Ok, I came up with something on my own. It seems to work pretty well and I
    would like to share it in case someone else needs it.
    Private Sub CommandButton1_Click()
    Do
    Calculate
    Loop Until [J3] = [J15] Or [J4] = [J15] Or [J5] = [J15] Or [J6] = [J15] Or
    [J7] = [J15] Or [J8] = [J15] Or [J9] = [J15] Or [J10] = [J15] Or [J11] =
    [J15] Or [J12] = [J15] Or [K3] = [J15] Or [K4] = [J15] Or [K5] = [J15] Or
    [K6] = [J15] Or [K7] = [J15] Or [K8] = [J15] Or [K9] = [J15] Or [K10] = [J15]
    Or [K11] = [J15] Or [K12] = [J15] Or [L3] = [J15] Or [L4] = [J15] Or [L5] =
    [J15] Or [L6] = [J15] Or [L7] = [J15] Or [L8] = [J15] Or [L9] = [J15] Or
    [L10] = [J15] Or [L11] = [J15] Or [L12] = [J15]
    [Exit Do]
    End Sub

    This is probably very simple for most of you, but it took me forever to find
    a solution <G>.
    Basically what this is doing is searching for a match from a block of 30
    cells (J3:L12) until one of them matches another cell (J15). Each of the
    aforementioned cells contains a =randbetween(1,20000) so it cycles through a
    ton of numbers for several seconds before hitting a match.

    "Fleone" wrote:

    > I would like to know how to run the Calculate function until a match between
    > two cells occurs.
    > With the help of Ikaabod, Niek and Gary's Student I created a series of
    > randomly generated numbers. I have a completely separate cell that is also
    > running the RANDBETWEEN function. I would like to have a button that when
    > pushed runs the Calculate command on the worksheet until a match occurs
    > between two cells that are generating random numbers.
    > Is this possible?
    > Thanks!


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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