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.
Bookmarks