Sherbetdab
Sherbetdab

Reputation: 127

Code stopping on =IFERROR(VLOOKUP)

I have the following line of code in a macro but the code keeps stopping when it reaches it.

With Range("L2:L" & ZRow)
    .Formula = "=IFERROR(VLOOKUP(A2,[WhoDidWhat.xlsx]Who_Did_What!$A:&H,7,0),VLOOKUP(B2,[WhoDidWhat.xlsx]Who_Did_What!$B:$H,6,0)"
    .Value = .Value
End With

If I put each VLookup in separately they both work apart from returning #NA hence the reason for using Iferror.

Can anyone point out where I might be going wrong or suggest another option?

Upvotes: 0

Views: 51

Answers (1)

Clement B
Clement B

Reputation: 218

I just think you have a problem with the first VLOOKUP when you are trying to get cells of Who_Did_What.

Replace VLOOKUP(A2,[WhoDidWhat.xlsx]Who_Did_What!$A:&H,7,0)

by VLOOKUP(A2,[WhoDidWhat.xlsx]Who_Did_What!$A:$H,7,0)

(the problem is maybe because of the second "$", you misplaced "&" instead)

Edit:

You also forgot a ")".

Clément

Upvotes: 1

Related Questions