Are these Cells in an Excel instance or a MSFlexGrid Instance?
SpiritualMadMan
Junior Poster in Training
70 posts since Sep 2010
Reputation Points: 49
Solved Threads: 5
Understandable.
I thought you were working with an Excel instance inside a VB6 project.
But, from what has been said it is actually a VBA "macro" in a Workbook?
My Excel VBA work is extremely limited.
Updating the display always takes time and while you may not think it was much of an improvement it does add up in a loop.
The only suggestion I can come up with is to take a look at how your Workbook is constructed.
What I am saying is that the way the Sheet is structured makes simplifying the loop "difficult".
If only one cell offset was being checked then you could do a select case after assigning the cell contents to a temporary variable.
I am not sure, because I haven't done this particular task before, but, I think it takes additional time to go retrieve the value each time instead of getting the value once and comparing it multiple times.
But, it looks like you have specific ranges of values based on the cell offset and that makes it hard to simplify.
If we had some idea of how the sheet was being constructed it might help us help you.
But, right now I can't see where an improvement can be had.
Wish I did more Excel VBA stuff.
Sorry.
SpiritualMadMan
Junior Poster in Training
70 posts since Sep 2010
Reputation Points: 49
Solved Threads: 5
No Fault about VBA, VBA and VB6 are pretty much the same thing anyway. Except VBA adds the unique bits and pieces for the Office Apps.
I am only guessing that going out and getting data from a cell takes a discrete amount of time, *possibly* a little more than a variable.
You said the data was in a list structure?
What would the list column headings be?
Are you inputting the list into Excel, then running your routine?
Are you "tied" to Excel? Or, asked differently, is the data source the Excel Worksheet?
This is an old version of a program I wrote that has a data importing function
http://www.houseofmyrrh.com/text2dao.htm
It was originally concieved to import delimited text files and create a database from them for the old version of the e-Sword Bible Study Program... It also (there are bugs mostly places where I haven't trapped for nulls in the data) allows the user to open an unknown database and see it's contents and structure...
There might be something about it that strikes your fancy?
If you were only testing a single coordinate position (offset) then I'd say use a Select Case instead...
Another trick is to, as much as possible, place the Cell test you think you will encounter most frequently at the top of your testing structure.
In other words if you look at the sheet and it looks like most of the Cells are empty, then do the empty test first so you drop out of the elseif list sooner.
SpiritualMadMan
Junior Poster in Training
70 posts since Sep 2010
Reputation Points: 49
Solved Threads: 5
Doh! I didn't even see that one! And, it's a good and "obvious" one, too.
SpiritualMadMan
Junior Poster in Training
70 posts since Sep 2010
Reputation Points: 49
Solved Threads: 5