PDA

View Full Version : Excel Programming Question


TripleS
Jun16-07, 05:30 AM
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?

Integral
Jun16-07, 03:26 PM
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.

TripleS
Jun16-07, 08:23 PM
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