How Can I Access a Subprogram on a Separate Screen in Excel?

  • Thread starter Thread starter TripleS
  • Start date Start date
  • Tags Tags
    Excel Programming
AI Thread Summary
The discussion revolves around creating a "Deal or No Deal" game in Excel using VB script. The user has implemented a randomization feature for money values in briefcases but faces a challenge in executing this randomization when the Excel workbook opens. The subprogram responsible for this randomization is located in a different part of the Excel object structure, making it inaccessible from the 'This Workbook' screen. Suggestions include declaring a function in a VB module to allow Excel to recognize and execute the subprogram. However, the user is still seeking a solution to ensure the randomization code runs correctly upon opening the workbook without directly copying the entire code, which would lead to issues with object references.
TripleS
Messages
22
Reaction score
0
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?
 
Technology news on Phys.org
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.
 
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 doesn't know where it is, and if i put the whole code in, it can't find that the objects to which the code is attached to...

hope you got that
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top