+ Reply to Thread
Results 1 to 9 of 9

Having problem with a nested FOR loop

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Having problem with a nested FOR loop

    Hi, I'm trying to run a nested loop, but receiving an error message. I'd much appreciate if somebody could "fix" this specific code .. By the way the aim is to fill up what I called "Ranking Table" in the sample.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Please * if you like the answer

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Having problem with a nested FOR loop

    I think you have written
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Having problem with a nested FOR loop

    In your second For Loop you used o Alpha instead of 0.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    02-09-2014
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    69

    Re: Having problem with a nested FOR loop

    The second for next loop needs to be;

    Please Login or Register  to view this content.
    (you have an 'o')
    Last edited by ihmha; 03-03-2014 at 03:39 AM.

  5. #5
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Having problem with a nested FOR loop

    Thanks everyone. Fixed it, and now the sub returns run time error 1004, application/object defined error..

  6. #6
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Having problem with a nested FOR loop

    You may not resize range to 0 - perhaps you intended Offset instead of Resize?

    What is ranking you wish to perform - each item within same year? Perhaps you wish:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Having problem with a nested FOR loop

    There are 6 cities (a-f), I try to find its relative ranking in each year (2002-2012). For instance, "city a" is ranked sixth in 2002 (since -6613 is the lowest number for 2002).

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Having problem with a nested FOR loop

    Did you try code I have posted?

  9. #9
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Having problem with a nested FOR loop

    @Izandol - I missed it somehow. It works perfectly. Many thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Nested For Loop
    By jbuckets in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-15-2012, 10:49 PM
  2. Nested Loop problem/Algorithm
    By Asad74 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2012, 09:36 PM
  3. Next without For error in nested loop - Escaping a Nested Loop?
    By BeneRich in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2012, 06:38 PM
  4. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 AM
  5. nested Loop
    By iturnrocks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2008, 07:26 PM

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