Conceptual Issue: Loops

ease20022002

Board Regular
Joined
Jun 4, 2005
Messages
233
Hi Guys,

Say for example that I have nested loops based off of two variable arrays.
Say there are two values in the first array and nine values in the second array.

Say the first value needs to be "compared" with every value in the second array, but the second value of the first array only needs to be compared with the last three values of the second array.

Code:
All_Lines = Array("HO", "ALLD")
All_DataType = Array("CWTC", "CWTO", "CWTT", "DOMC", "DOMO", "DOMT", "CWXC", "CWXO", "CWXT")

I know how to setup a "static" loop:

Code:
For DLine = 0 To UBound(All_Lines)
        For DType = 6 To UBound(All_DataType)

This does get the job down with what I explained earlier, but what if the array changes, etc., and I decide to make this more of a dynamic array and 1 day the values in the first array need to be compared to different values in the second array...Is there a better way to set this up? Would a scripting dictionary approach be better, etc...

I welcome all comments and advice. I am just trying to think of ways to make this loop with the current array setup more dynamic...b.c if i change values in the arrays, or rearrange them, the loop will not work correctly.

The reason for this loop is to obtain data from a database. I can't simply have each All_Lines values be combined with All_Datatypes b.c I would be retrieving way too much data. We don't need each to be compared. What would be the best way to have selective comparrision between arrays, or dynamic...etc... If anyone still has anymore questions, please let me know..

I appreciate any help... [/code]
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top