+ Reply to Thread
Results 1 to 5 of 5

Many Nested loops

  1. #1
    naterator
    Guest

    Many Nested loops

    I'm still fairly new to programming excel but I understand basic programming
    concepts and logic. I have four arrays called stgOffers, stgOffdups,
    stgClients1, stgClients2. Here's what I'm looking to do:

    Layout of data -- in column b are clients and they're housed in the array
    stgClients2 In column c are entries that may be duplicates. these entries
    are housed in the array stgOffdups. In a separate worksheet I have a column
    with entries that are stored in stgOffers. In yet another worksheet I have a
    column with entries that are stored in stgClients1.

    What to do -- I need a loop that will take the first entry of stgOffers
    (call it A) and then compare each entry of stgOffdups to A. If any entry in
    stgOffdups = A then I need to compare the first entry of stgClients1 (call it
    B) to every entry in stgClients2. Now, whenever an entry of stgClients2 = B,
    I need to perform a specific action. I can code the specific action (I
    think) but I can't seen to get this massive If For Next Then off the ground.

    If anyone can give me a hand I would be most appreciative. Please send me
    an email at [email protected] if you would like to see the code that
    I have right now.

    Thanks again!
    Nate

  2. #2
    Bob Phillips
    Guest

    Re: Many Nested loops

    Are these VBA arrays or range names?

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "naterator" <[email protected]> wrote in message
    news:[email protected]...
    > I'm still fairly new to programming excel but I understand basic

    programming
    > concepts and logic. I have four arrays called stgOffers, stgOffdups,
    > stgClients1, stgClients2. Here's what I'm looking to do:
    >
    > Layout of data -- in column b are clients and they're housed in the array
    > stgClients2 In column c are entries that may be duplicates. these entries
    > are housed in the array stgOffdups. In a separate worksheet I have a

    column
    > with entries that are stored in stgOffers. In yet another worksheet I have

    a
    > column with entries that are stored in stgClients1.
    >
    > What to do -- I need a loop that will take the first entry of stgOffers
    > (call it A) and then compare each entry of stgOffdups to A. If any entry

    in
    > stgOffdups = A then I need to compare the first entry of stgClients1 (call

    it
    > B) to every entry in stgClients2. Now, whenever an entry of stgClients2 =

    B,
    > I need to perform a specific action. I can code the specific action (I
    > think) but I can't seen to get this massive If For Next Then off the

    ground.
    >
    > If anyone can give me a hand I would be most appreciative. Please send me
    > an email at [email protected] if you would like to see the code

    that
    > I have right now.
    >
    > Thanks again!
    > Nate




  3. #3
    Tom Ogilvy
    Guest

    RE: Many Nested loops

    You use the term array, but then imply that these are actually range
    references?

    if these are references to ranges:

    Dim cell as Range, cell2 as Range
    Dim a as variant, b as variant
    set cell = stgOffers(1)
    A = cell.Value
    if application.Countif(stgOffdups,A) > 0 then
    b = stgClients1(1).Value
    for each cell2 in stgClients2
    if cell2.Value = b then
    ' perform a specific action
    end if
    next cell2
    end if


    My guess is this isn't exactly what you want, but it is exactly what you
    described.

    --
    Regards,
    Tom Ogilvy

    "naterator" wrote:

    > I'm still fairly new to programming excel but I understand basic programming
    > concepts and logic. I have four arrays called stgOffers, stgOffdups,
    > stgClients1, stgClients2. Here's what I'm looking to do:
    >
    > Layout of data -- in column b are clients and they're housed in the array
    > stgClients2 In column c are entries that may be duplicates. these entries
    > are housed in the array stgOffdups. In a separate worksheet I have a column
    > with entries that are stored in stgOffers. In yet another worksheet I have a
    > column with entries that are stored in stgClients1.
    >
    > What to do -- I need a loop that will take the first entry of stgOffers
    > (call it A) and then compare each entry of stgOffdups to A. If any entry in
    > stgOffdups = A then I need to compare the first entry of stgClients1 (call it
    > B) to every entry in stgClients2. Now, whenever an entry of stgClients2 = B,
    > I need to perform a specific action. I can code the specific action (I
    > think) but I can't seen to get this massive If For Next Then off the ground.
    >
    > If anyone can give me a hand I would be most appreciative. Please send me
    > an email at [email protected] if you would like to see the code that
    > I have right now.
    >
    > Thanks again!
    > Nate


  4. #4
    Otto Moehrbach
    Guest

    Re: Many Nested loops

    I agree with Tom that this isn't what you wanted but it is what you
    described. You chose the first value of the first column and you didn't say
    that you wanted to loop through all the cells of the first column. Do you?
    HTH Otto
    "naterator" <[email protected]> wrote in message
    news:[email protected]...
    > I'm still fairly new to programming excel but I understand basic
    > programming
    > concepts and logic. I have four arrays called stgOffers, stgOffdups,
    > stgClients1, stgClients2. Here's what I'm looking to do:
    >
    > Layout of data -- in column b are clients and they're housed in the array
    > stgClients2 In column c are entries that may be duplicates. these entries
    > are housed in the array stgOffdups. In a separate worksheet I have a
    > column
    > with entries that are stored in stgOffers. In yet another worksheet I have
    > a
    > column with entries that are stored in stgClients1.
    >
    > What to do -- I need a loop that will take the first entry of stgOffers
    > (call it A) and then compare each entry of stgOffdups to A. If any entry
    > in
    > stgOffdups = A then I need to compare the first entry of stgClients1 (call
    > it
    > B) to every entry in stgClients2. Now, whenever an entry of stgClients2 =
    > B,
    > I need to perform a specific action. I can code the specific action (I
    > think) but I can't seen to get this massive If For Next Then off the
    > ground.
    >
    > If anyone can give me a hand I would be most appreciative. Please send me
    > an email at [email protected] if you would like to see the code
    > that
    > I have right now.
    >
    > Thanks again!
    > Nate




  5. #5
    naterator
    Guest

    Re: Many Nested loops

    All,

    You're right. I didn't communicate my situation very well. I have a column
    of campaigns. On the right of this column I have another column filled with
    client names. Here's an example:
    COL A COL B
    jack camp1
    barb camp1
    jack camp2
    camp2
    jack camp3
    joe camp3

    In a different worksheet I have a column with nonduplicated campaign names.
    i.e.:

    Col C
    camp 1
    camp 2
    camp 3

    Now in yet another worksheet I have a column with the clients (no dups)
    Col D
    barb
    jack
    joe

    Now I need get the information from the first two columns COL A and B into a
    table in a new worksheet where the rows labels are the campaigns from Col C
    and the column labels are from Col D. So, I need to be able to go down COLs
    A & B, look at the entries, and then put a 1 in the proper location in my
    table. This seems easy if I can use array indexes. Does that clear any
    confusion? So yes, I do need to loop through the entries of COL A. The code
    supplied so far by you guys makes sense and is helpful. I'm just not sure I
    can fill the table in without indexes.

    BTW, I am enrolled in a VBA class set to start this fall. So, I am RTFM = )
    Until then though, thanks for all the help!!

    Nate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1