Adding formula to a cell with VB

  • Thread starter Thread starter Willow
  • Start date Start date
W

Willow

Hi

I need to add a formula to a cell ( actually a range of cells) uing
VB.

The formula is

=IF($U6="","",IF(OR($T6="Yes",$U6="Yes"),"HICA",IF($E6="No
Notice","CALL","Notice")))

I would like to use something like:

Range("V2").Formula = "=IF(OR(T2="Yes",U2="Yes"),"HICA",IF(E2="No
Notice","CALL","Notice"))"


My problem is that the quotes in the formula are read as the end of the
string in the vb. Could anyone help please?

Thanks
 
You need to use double (double double!) quotes:

Range("V2").Formula =
"=IF(OR(T2=""Yes"",U2=""Yes""),""HICA"",IF(E2=""No
Notice"",""CALL"",""Notice""))"
 
Willow,

The easiest way to get this right is to turn on the recorder and then
enter the formula into the cell.

Kind regards,
NickH
 
Willow,

The easiest way to get this right is to turn on the recorder and then
enter the formula into the cell.

Kind regards,
NickH
 
Back
Top