Combine 2 Loops

  • Hi
    I am a novice.


    In this code, I need to combine two "For" loops.


    Here my code goes. I am trying to develop a code to automatize my copy paste task in Excel. Breifly, a .wiff file organized as follows
    .wiff --> Samples-->Periods---> Experiments
    When the Value of exptNum changes, strRetTime should also change. i.e., I need to combine


    For exptNum = 0 To theWF.GetNumberOfExperiments(sampleNum, periodNum) - 1
    and
    For j = 0 To 1


    I searched the forum, but could find UNION for combining arrays.


    Your help is highly appreciated
    Regards,
    Rajan Kombu


  • Re: Combine 2 Loops


    Welcome to Oz, komburajan :)


    The reason that you haven't received a response is likely because you've posted more code than anyone wants to wade through to answer what may otherwise be a pretty simple question.


    If you can reduce it to 30 lines of code that illustrates the same problem, someone would probably respond.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Combine 2 Loops


    G'day komburajan,


    I have to agree with shg - tooooo much code.


    However, I did notice you have used 'j' to define 2 loops within the same macro - without going thru' the code line by line, you might try just redefining one of the 'j's to something else.


    I don't know if it have an impact, but when coding I always try and keep dim as completely separate entities so there is no possibility of confusion ...


    HTH


    GB

    But I always say luck is where preparation meets opportunity (Justin Langer 23/11/01)

  • Re: Combine 2 Loops


    Hi,
    Thank you for your replies...At first thought of giving a short code...but then thought that it would be useful if I give my complete code.
    Thanks for the advice.
    I have shortened the code. Please see below.
    What I need to do is:
    Instead of having this as a nested loop,
    when when j value changes to 0, automatically k value also should change to 0. Likewise when it goes to 1, k should turn to 1.
    In short whenever the j value advances to one number, k value should also advance to one number.
    Hope this helps. Please let me know if any questions are there.
    Thanks for your help in advance.

  • Re: Combine 2 Loops


    ......

    Quote

    when when j value changes to 0, automatically k value also should change to 0. Likewise when it goes to 1, k should turn to 1.
    In short whenever the j value advances to one number, k value should also advance to one number.

    Code
    k=j

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!