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...
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
8,306
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.
 

Forum statistics

Threads
1,141,227
Messages
5,705,142
Members
421,380
Latest member
Nuwan Sanjeewa Aponso

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top