vlookup - how to put this into VBA

M

Melbridge

This formula works in the cell but I need it in VBA and it doesn't want to
play!

The formula is in cell J4
=IF(I4=(VLOOKUP(K4,'E:\MANMON\TEAMS VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!$A$2:$C$40,3,FALSE)),"","88888888")

I have tried this:
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="(VLOOKUP(RC[+1],'E:\MANMON\TEAMS
VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!$A$2:$C$40,3,FALSE)","""",88888888))"

Is it just a formatting thing?
 
B

Bob Phillips

You are mixing R1C1 and A1

Try

Const sVLOOKUP As String = _
"VLOOKUP(RC[+1],'E:\MANMON\TEAMS VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!R2C1:R40C3,3,FALSE)"

ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=" & sVLOOKUP & ","""",88888888)"
 
M

Melbridge

Thanks Bob,

I'll have to remember that - I'm not a programmer (as you probably guessed),
I just cut n paste then modify!

--
Regards, Dean


Bob Phillips said:
You are mixing R1C1 and A1

Try

Const sVLOOKUP As String = _
"VLOOKUP(RC[+1],'E:\MANMON\TEAMS VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!R2C1:R40C3,3,FALSE)"

ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=" & sVLOOKUP & ","""",88888888)"


--
__________________________________
HTH

Bob

Melbridge said:
This formula works in the cell but I need it in VBA and it doesn't want to
play!

The formula is in cell J4
=IF(I4=(VLOOKUP(K4,'E:\MANMON\TEAMS VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!$A$2:$C$40,3,FALSE)),"","88888888")

I have tried this:
ActiveCell.FormulaR1C1 = "=IF(RC[-1]="(VLOOKUP(RC[+1],'E:\MANMON\TEAMS
VALIDATION\Teams
Master\[TEAMS_Master.xls]Officers'!$A$2:$C$40,3,FALSE)","""",88888888))"

Is it just a formatting thing?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top