Results 1 to 12 of 12

Loops within loops?

Threaded View

Coeus Loops within loops? 07-21-2013, 06:10 AM
AB33 Re: Loops within loops? 07-21-2013, 06:23 AM
Coeus Re: Loops within loops? 07-21-2013, 06:28 AM
mikerickson Re: Loops within loops? 07-21-2013, 06:24 AM
Coeus Re: Loops within loops? 07-21-2013, 06:25 AM
AB33 Re: Loops within loops? 07-21-2013, 06:39 AM
nilem Re: Loops within loops? 07-21-2013, 06:54 AM
AB33 Re: Loops within loops? 07-21-2013, 07:32 AM
Coeus Re: Loops within loops? 07-21-2013, 08:51 AM
AB33 Re: Loops within loops? 07-21-2013, 09:29 AM
nilem Re: Loops within loops? 07-21-2013, 09:45 AM
AB33 Re: Loops within loops? 07-21-2013, 09:55 AM
  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Loops within loops?

    Hi all,

    Hope all is well in your macro worlds and beyond!

    Trying to accomplish a loop within a loop for LOOKUP data from 12 worksheets into a summary sheet.

    The macro is meant to do the following:
    1. Check if column B in the summary sheet contains a value - if so:
    a) Input into column G in the summary sheet a VLOOKUP to that data sheet to pull in a value (or 0.00 IFERROR).
    b) Do as (1a) for each of the 12 data sheets (columns G to R in total).
    c) Cycle through each code in column B completing (1a) and (1b).
    2. Otherwise cycle through to the next code in column B.

    I get an object defined error on my FormulaR1C1 - I think I have not correctly written it so the macro can use the k variable for each data worksheet number (1-12).

    I have posted the formula and worksheet:

     Sub VLOOKUP_DATA()
    
        'Turns off screen updating.
        Application.ScreenUpdating = False
        
        
        '****************************** LOOKUP LOOP *****************************
    
        'Variable for the codes column.
        For i = 14 To 1000
        
        'Check a code exists in the code column.
        If Sheets("Summary").Cells(i, 2) <> 0 Then
        
        'Variable for the monthly data columns.
        For j = 6 To 16
        
        'Variable for the montly data sheet names.
        For k = 1 To 12
        
        'Formula to look up the 7th column in each monthly data sheet.
        Sheets("Summary").Cells(i, j).FormulaR1C1 = _
            "=IFERROR(VLOOKUP(RC[-j+1], 'Data - Month & k'!C[-j]:C, 7, FALSE),0)"
        
        Next k
        
        Next j
        
        End If
        
        Next i
        
    
        '****************************** CLOSE *****************************
    
        'Turns on screen updating.
        Application.ScreenUpdating = True
    
    
    End Sub


    I would greatly apprecaite any input on correcting / improving my code if willing!


    Many thanks for any help in advance!


    Coeus.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Do until loops
    By tryer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2011, 11:03 AM
  2. Loops
    By TheGainmaker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2011, 12:04 PM
  3. VBA Loops
    By mistadarcy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2011, 01:57 PM
  4. Loops...
    By Willabo in forum Excel General
    Replies: 2
    Last Post: 06-14-2006, 11:15 AM
  5. For next loops
    By Kate in forum Excel General
    Replies: 5
    Last Post: 05-22-2006, 08:15 AM

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