Understanding scope

medic5678

Board Regular
Joined
Nov 13, 2018
Messages
67
In order to have a variable visible to all controls in a particular form, does it need to be global? Is there a way to declare a variable to have the scope of all procedures triggered by controls in a from, or would you need to put all the code for the subroutines in a module, with a module scoped varaible?

assuming userform1 with 10 controls, all manipulating the same array.

When the form in initiated, can you declare the array there, in such a way that all the controls would have access to the array, but the array wouldn't have scope to anything outside the form?
 
The people here have been phenomenal. When you're new to this, you have no clue how to get started. I've tried to take VBA classes, but I just can't suffer through them, as my internet is so lousy (satellite, I live in Timbuktoo) I can't watch the videos without constant stopping/stalling. There's no substitute for doing and to be able to ask a question here and have someone take time to answer it (clueless newbies can be dumber than rocks), is an enormous help. Actually just a few days away from finishing my first VBA application. It's all starting to gel.

True.

Although I am longtime user of excel/vba and a veteran member in this forum, I am still amazed at the number of knowledgeable and friendly people that come here from different countries and cultures with a shared goal of willing to offer their expertise to help others.... I personally learnt a great deal here and owe this forum most of what I know by answering questions and by reading other member's answers.

I am happy you had a pleasant visit here and wish you all the best with your learning process.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

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
Back
Top