![]() |
Adding formula to a cell with VB
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 -- Willow ------------------------------------------------------------------------ Willow's Profile: http://www.excelforum.com/member.php...o&userid=16070 View this thread: http://www.excelforum.com/showthread...hreadid=564642 |
Adding formula to a cell with VB
You need to use double (double double!) quotes: Range("V2").Formula = "=IF(OR(T2=""Yes"",U2=""Yes""),""HICA"",IF(E2= ""No Notice"",""CALL"",""Notice""))" -- lucidr ------------------------------------------------------------------------ lucidr's Profile: http://www.excelforum.com/member.php...o&userid=36699 View this thread: http://www.excelforum.com/showthread...hreadid=564642 |
Adding formula to a cell with VB
Thanks - I knew it was something simple. -- Willow ------------------------------------------------------------------------ Willow's Profile: http://www.excelforum.com/member.php...o&userid=16070 View this thread: http://www.excelforum.com/showthread...hreadid=564642 |
Adding formula to a cell with VB
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 |
Adding formula to a cell with VB
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 |
All times are GMT +1. The time now is 04:00 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com