Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Excel Programming Question

  1. Jun 16, 2007 #1
    I am using the VB script that is already in Excel, and I am making a program similar to that "Deal or No Deal" show that airs in many countries.
    The concept of the game is where there is a certain number of briefcases, and there is a money value in each of those. You choose one, and slowly choose other briefcases. The aim is to keep the most money in the unopened briefcases to generate the largest bank offer (where a 'bank' tries to buy your briefcase on the chance of that briefaces to have a certain amount of money)

    In the main game screen where one chooses the briefcase I have put in a code the randomises the 18 possible money values for the 18 briefcases. I need that randomisation to occur when Excel is opened up, but the subprogram with the randomisation and intialisation of variables is on a separate screen (which has its own code), which I cannot access from the 'This Workbook' screen.

    Does anyone know of a way to bypass this, so i can access the subprogram i need?
     
  2. jcsd
  3. Jun 16, 2007 #2

    Integral

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Not sure that I completely understand your problem, or what it is you want to do but...

    If you declare a Function in a VB module, Excel will use it just as it uses any Excel function. So if I declare

    Function XYZ( a as integer, b as double)
    .
    .
    end

    I can then write = XYZ(a1, a2) in a cell. Excel will execute the VB function.
     
  4. Jun 16, 2007 #3
    okay....let me try and reiterate
    There is a subprogram that randomises the money values for each briefcase
    that is in a particular spot (in a 'screen' of Microsoft Excel Objects), and i need that section of code to run when the program is opened up. But if i simply put GameSetup (name of the subprogram), it doesnt know where it is, and if i put the whole code in, it cant find that the objects to which the code is attached to...

    hope you got that
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Excel Programming Question
  1. An Excel question (Replies: 4)

  2. 2 programming questions (Replies: 10)

Loading...