VBA - passing variables to Form Subs

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
i'm trying to write a small app which will have one main User Form...
usually i get around variables by writing and retrieving data to/from worksheet cells...
this time around though i'd like to see if i could do everything right in the vba (ie instead of going to the worksheet)...

here's a part of what i'd like to do...
1) when the form loads up i run a module to initialize the form and variables...eg let's say i have a variable vStatus that I want to hold the value new.....----- vStatus="New"
2) on the form i have multiple command buttons ....i want to read the value of vStatus and if it's New then if i hit one group of buttons (let's say the group of buttons i have at the top of the form) i want to change vStatus to a new value eg...."Top" and if i hit another group of buttons (let's say the group of buttons at the bottom of the form) then i want to change vStatus to "Bottom"

I'm sure it's not very difficult but i've never really done anything like this without storing and retrieving from worksheet cells...so any help would be great...thanks...
 

Some videos you may like

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,930
Office Version
  1. 2016
Platform
  1. Windows
Have a look at Module level or Public variables which can be seen globally by different Modules and Procedures.

Regards.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,810
Messages
5,525,017
Members
409,615
Latest member
papaluigi94

This Week's Hot Topics

Top