What are the advantages and disadvantages of Passed Arrays vs Global Arrays in Excel VBA

Well, the second attempt to write a question, so forgive me if this seems familiar.

I am rewriting an Excel macro that was built in 2 1/2 years, Frankenstein style (added in parts). One of the things I need to do is load the data into the array once and only once for the accuracy and speed of the data. For my skill level, I will stick with the Array methodology.

My two approaches:

  • Using global dynamic arrays with dimming
  • Change dynamic arrays in my main procedure and pass them to the called procedures

So, what is stack overflow, take a Pro versus against these two methods? Thanks, Craig ...

+3
source share
2 answers

First, to answer a question that you didn’t specifically ask: set up your own class and load the data. Seriously, you will thank me later.

OK, to your question. I start by limiting the volume as much as possible. This means that I pass variables between procedures. When all your variables have the most restrictive scope, you are faced with the least problems in the line.

( 1- , 1- 2- ), . ( ), , ( Private Dim). ( ), .

, : , ; , , ; ( , ), , . , , .

, . - . , , , .

, , . , , .

, : , . ,

ActiveCell.Value = Invoice.LocalSalesTaxAmount

,

ActiveCell.Value = aInvoice(35,2)

, , - , . , .

+9

globals Excel VBA, , - reset ( ), .

, .

+2

Source: https://habr.com/ru/post/1731105/


All Articles