Global variables in VBA

Please post any questions regarding the program here.

Moderator: 2020vision

Global variables in VBA

Postby Captain Sensible » Mon Apr 07, 2014 5:56 pm

Does VBA use global variables? In php I use a lot of session tokens basically just variables that can be accessed from memory in any routine. Is there a way I can also store VBA variables that can be used within any sub routine?

I have a few routines that run at a change in market and it seem pointless to have to rerun routines to get those variables again, I could echo them to the sheet but I'm guessing vba must handle global variables I just don't know the syntax
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm

Postby osknows » Mon Apr 07, 2014 8:46 pm

Hi Captain,

In a MODULE set the variable as PUBLIC, it's then accessible by all sheets, modules and classes.

eg
Code: Select all
Public modVar2 As String


this is a useful link if you want more info http://www.cpearson.com/excel/scope.aspx
User avatar
osknows
 
Posts: 946
Joined: Wed Jul 29, 2009 12:01 am

Postby Captain Sensible » Mon Apr 07, 2014 10:55 pm

Thanks Osknows, I did a bit of searching and came up with the public thing. Hopefully all will be OK for testing tomorrow :)
User avatar
Captain Sensible
 
Posts: 2923
Joined: Sat Nov 19, 2005 2:29 pm


Return to Help

Who is online

Users browsing this forum: Google [Bot] and 61 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.