Hi Octo,
Thank you very much for the rep points.
I think you are missing the .FindNext call to find further values. See the following example code (included in the atttached file) which may help you. It is combines two solutions in one:
a. Use of a Dynamic Array
b. Use of a Dynamic Array of a Structure
Key Points:
a. Option Explicit - To prevent typos from ruining days and weeks of work 'Option Explicit' is NEEDED at the top of each code module. This prevents errors caused by missspellings and FORCES every variable to be DECLARED (e.g. Dim i as Integer). http://www.cpearson.com/excel/DeclaringVariables.aspx
b. Structure Definition - It should go after 'Option Explicit' and before the first routine (Sub or Function).
c. Creation of Dynamic Array and Dynamic Structure Array - Notice that there are no dimensions inside.
d. Initialization of the items created in c. above. The method I use is probably not the best way to do things, but it has always worked for me without problems. Redim expands (or contracts) the array size and removes any existing data. Please note that the Redim command can be tricky when using multi-dimensional arrays
e. Putting data in the arrays. Redim Preserve expands (or contracts) the array size and keeps any existing data.
f. Offset command. The syntax is Offset(number of rows, number of columns). r.Offset(0,1) means take the address of r and move it 1 column to the right.
----------------
Debugger Secrets:
a. Press 'F8' to single step (goes into subroutines and functions).
b. Press SHIFT 'F8' to single step OVER subroutines and functions.
c. Press CTRL 'F8' to stop at the line where the cursor is.
d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
output to the IMMEDIATE WINDOW.
f. Select View > Locals to see all variables while debugging.
g. To automatically set a BREAKPOINT at a certain location put in the line:
'Debug.Assert False'
h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
if i >= 20 and xTV20 > 99.56 then
Debug.Assert False
endif
i. A variable value will be displayed by putting the cursor over the variable name.
I hope this helps.
Lewis
Bookmarks