Forum Discussion
Dim - declaring varialbes
Thanks Peter and sorry for my late reply. PeterBartholomew1 .
I am ok with a define name and ranges. What isn't clear for me IS what to declare, in your example you have declared Dim vStatus, so please why not the "query ID" or the "ID"?
Also, please for this example why have you declare the vStatus and not the whole workbook or worksheet?
Many Thanks,
Maddy
Agreed, to do any serious programming you are likely to need to read data arrays from more than one range. It is possible to read data cell by cell but reading an entire range into a 2-dimensional variant array is far more efficient. The default workbook for reading and writing is the 'ActiveWorkbook', though it is possible to interact with other workbooks including 'ThisWorkbook' which contains the code (often the same workbook).
The most commonly-used Names are scoped to the workbook and will be used by default; the RefersTo property of the Name contains the Sheet so reading the range will return values from the correct sheet.
If you wish to add one or more sheets to the workbook then you would be using the Add method of the workbook Sheets object but I have no reason to believe you are trying to do 'fancy' things like that!