Excel convert cell formula to vba FormulaR1C1

Hello,

I'm trying to convert the formula below to excel VBA a line of FormulaR1C1 code without success. Please help as I keep getting error 1004.

=IF(IF(ISERROR(VLOOKUP(Q3,dataLU1!$D$1:$D$200,1,0)),"",Q3)="","x xx "&U3,A3)

The formula goes in column "V"

Do

ActiveCell.FormulaR1C1 = "=IF(IF(ISERROR(VLOOKUP(RC[-5],dataLU1!R1C4:R200C4,1,0)),"",RC{[-5]="""",&""x xx""&RC[-1],RC[-21])"
ActiveCell.Offset(1, 0).Select

Loop Until IsEmpty(ActiveCell.Offset(0, -21))

Open in new window

sq30Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saurabh Singh TeotiaCommented:
SQ30,

Quick question which Column you want to apply this formula??

Saurabh...
0
sq30Author Commented:
Saurabh "V" please
0
Saurabh Singh TeotiaCommented:
You don't need a loop statement you..can simply do this...

Dim lrow As Long

lrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row

Range("V3:V" & lrow).Formula = "=IF(IF(ISERROR(VLOOKUP(Q3,dataLU1!$D$1:$D$200,1,0)),"""",Q3)="""",""x xx ""&U3,A3)"

Open in new window


Saurabh...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Rgonzo1971Commented:
Hi,

pls try
Set myrange = Range(Range("V3"), Range("V" & Range("A" & Rows.Count).End(xlUp).Row))
myrange.Formula = "=IF(IF(ISERROR(VLOOKUP(Q3,dataLU1!$D$1:$D$200,1,0)),"""",Q3)="""",""x xx ""&U3,A3)"

Open in new window

Regards
0
sq30Author Commented:
Thank you and I can't believe how fast that works.
0
sq30Author Commented:
Sorry Rgonzo1971 I've just noticed your comment but Saurabh has worked perfect for me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.