+ Reply to Thread
Results 1 to 10 of 10

Increment two variables in the" For" loop

  1. #1
    Registered User
    Join Date
    09-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    5

    Increment two variables in the" For" loop

    Hello!

    Has anyone been dealing with having more variables to increment in the loop?

    For example:

    Please Login or Register  to view this content.
    I dont know..maybe there is another statement for that.

    Thanks for attention!

    Kirill
    Last edited by Cutter; 09-04-2012 at 01:44 PM. Reason: Replaced ITALIC tags with CODE tags

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Increment two variables in the" For" loop

    Kirill,

    Welcome to the forum!
    When you want to do something like this, you usually have a nested loop, like so:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    09-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Increment two variables in the" For" loop

    Thanks, tigeravatar for fast response and hostility!

    But now I understand that my problem is a bit more complicated...

    Because my code is like that:

    Please Login or Register  to view this content.


    where x is a column where to paste copied data, but it seems that it takes Q number one every time instead of incrementing it simulteniously with x..

    hope it is not confusing

    Kirill
    Last edited by Cutter; 09-04-2012 at 01:45 PM. Reason: Replaced ITALIC tags with CODE tags

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Increment two variables in the" For" loop

    What sheet do you want to paste the results to?

  5. #5
    Registered User
    Join Date
    09-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Increment two variables in the" For" loop

    its sheet "Area". This sheet is the last. And column "C" from all sheets going before "Area" are transformed into histogram resulting in the sheet "Area" in the columns "U" (Bins) and "V" (Frequency). But then the macro copy column "V" to the beginning of the sheet starting in the column B and then C, D and so on for each new frequency column...omg this logic sucks :D I will understand if you give it up...

    anyway thanks!

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Increment two variables in the" For" loop

    @ kirill8910

    Welcome to the forum.

    Please notice that code tags have been added to your posts in place of the italic tags that you used. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Increment two variables in the" For" loop

    Give this a try:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Increment two variables in the" For" loop

    wow that does the trick! combine For and If ..nice Thanks, tigeravatar!

    @ Cutter

    shame on me, must read rules first

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Increment two variables in the" For" loop

    @ kirill8910 (just in case you procrastinate like I do):

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  10. #10
    Registered User
    Join Date
    09-04-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Increment two variables in the" For" loop

    yea I'm professional procrastinator :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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