Srinivash
Srinivash

Reputation: 1

How to set a formula in particular cells in excel using VBA?

I want to set the following formula(its already working fine) in first 1000 rows in excel.Actually I am looking in VBA. But, I am not familiar in VBA code.

=IFERROR(VLOOKUP(DD,HDR_COLMN,COLUMN(),0),"")

DD - getting data from another sheet

HDR_COLMN - getting table header from another sheet(Sheet2) and showing as drop down values in Sheet1

Please any one can help me. Advance thanks

Upvotes: 0

Views: 839

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

The only tricky part is the double-quotes.

Say we want to deposit this with VBA

=IFERROR(VLOOKUP(A1,B1:C10,2,TRUE),"")

This will do it:

Sub luxation()
    Range("A10").Formula = "=IFERROR(VLOOKUP(A1,B1:C10,2,TRUE),"""")"
End Sub

Upvotes: 1

Related Questions