Hello all,
The following code retrieves values from sheet "WERKBLAD".
Now I'd like to extend it with 2 more sheets "WERKBLAD2" and "WERKBLAD3".
Is it possible to change the formula below so it looks for matches in all 3 the sheets.
The layout of all 3 the sheets are the same.
With Worksheets("Urenstaat") TopRow = .Range("D" & Rows.Count).End(xlUp).Row + 1 lastrow = .Range("A" & Rows.Count).End(xlUp).Row If TopRow < lastrow Then With .Range("D" & TopRow & ":D" & lastrow) .FormulaR1C1 = "=IF(RC[-3]=""Werknemer:"","""",VLOOKUP(INDEX(WERKBLAD!R6C4:R5000C256,MATCH(RC[-3],WERKBLAD!R6C2:R5000C2,0),MATCH(LOOKUP(2,1/(R6C1:RC[-3]=""Werknemer:""),R6C2:RC[-2]),WERKBLAD!R5C4:R5C256,0)),IMPORT!R3C7:R300C11,2,FALSE))" .Value = .Value End With End If End With
Impossible?
All help is welcome
Well, I don't know a lot about what worksheet functions do, and the following code is not tested to your workbook criteria, and it may be a little crude compared to what the gurus would do, here is a hopeful:Sub Jonathan78() With Worksheets("Urenstaat") TopRow = .Range("D" & Rows.Count).End(xlUp).Row + 1 lastrow = .Range("A" & Rows.Count).End(xlUp).Row If TopRow < lastrow Then With .Range("D" & TopRow & ":D" & lastrow) .FormulaR1C1 = "=IF(RC[-3]=""Werknemer:"","""",VLOOKUP(INDEX(WERKBLAD!R6C4:R5000C256,MATCH(RC[-3],WERKBLAD!R6C2:R5000C2,0),MATCH(LOOKUP(2,1/(R6C1:RC[-3]=""Werknemer:""),R6C2:RC[-2]),WERKBLAD!R5C4:R5C256,0)),IMPORT!R3C7:R300C11,2,FALSE))" .Value = .Value End With End If End With With Worksheets("Urenstaat") TopRow = .Range("D" & Rows.Count).End(xlUp).Row + 1 lastrow = .Range("A" & Rows.Count).End(xlUp).Row If TopRow < lastrow Then With .Range("D" & TopRow & ":D" & lastrow) .FormulaR1C1 = "=IF(RC[-3]=""Werknemer:"","""",VLOOKUP(INDEX(WERKBLAD2!R6C4:R5000C256,MATCH(RC[-3],WERKBLAD2!R6C2:R5000C2,0),MATCH(LOOKUP(2,1/(R6C1:RC[-3]=""Werknemer:""),R6C2:RC[-2]),WERKBLAD2!R5C4:R5C256,0)),IMPORT!R3C7:R300C11,2,FALSE))" .Value = .Value End With End If End With With Worksheets("Urenstaat") TopRow = .Range("D" & Rows.Count).End(xlUp).Row + 1 lastrow = .Range("A" & Rows.Count).End(xlUp).Row If TopRow < lastrow Then With .Range("D" & TopRow & ":D" & lastrow) .FormulaR1C1 = "=IF(RC[-3]=""Werknemer:"","""",VLOOKUP(INDEX(WERKBLAD3!R6C4:R5000C256,MATCH(RC[-3],WERKBLAD3!R6C2:R5000C2,0),MATCH(LOOKUP(2,1/(R6C1:RC[-3]=""Werknemer:""),R6C2:RC[-2]),WERKBLAD3!R5C4:R5C256,0)),IMPORT!R3C7:R300C11,2,FALSE))" .Value = .Value End With End If End With End Sub
Please leave a message after the beep!
Hello Mordred,
Thanks for trying but this doesn't work.
The code inserts the formula.
Your code just overwrites the others the formula.
Any other ideas?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks