excel vba - VBA Clean use of many Constants -


My Excel VBA ~ takes 300 xls file and grabs 8 cells to submit it to its line (Office11) I have several sub-screens and functions that use location constants for source data and destination. In the Grand Total I have 23 continuous locations with column number, cell place.

Question: Any suggestion on how to clean it to keep readability and all at one place? I was trying to avoid the public variable, but how to arrays with stable values ​​not ensured in a better way?

Particular example, the string pstrQLocations (1 to 8) as the string
pstrQLocations (1) = "B7"
pstrQLocations (2) = "B6"
pstrQLocations (3) = "b5"
pstrQLocations (4) = "b8"
pstrQLocations (5) = "A3"
pstrQLocations (6) = "C8"

You can store your constants in a archive The advantage is , That you can give the names of your elements

"B6", "user" end sub private sub-show () initialize debug debuggable. Print. Category debug (pstrQLocations ("title")). Print me Category (pstrQLocations ("user")). Value End Sub

3D version:

  as archive option explicitly pstrldoconations collection set new collection as private sub initializeConstants () Dim titles PstrQLocations = new archive title. Add "B7", "Source" title. Add "A6", "Destination" pstrQLocations.Add Title, "Title" end sub-private sub showConstants (initially) as Dim Y archive Debug. Print pstrQLocations ("title") ("source") debug .prust pstrQLocations ("title") ("destination") ending sub  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -