![]() |
If statement in VBA
Hi I'm using the following formula in a routine:
Range("G11:CX298").Formula = "=IF(AND($DX11<$B11,$G11="".""),$DZ11)" If the criteria = true then it placecs the value of $DZ11 which is wan I want. What do I put in for the false part of the statement if I want to tak no action? I don't want to clear or change the contents at all if th condition is false. Thank -- Message posted from http://www.ExcelForum.com |
If statement in VBA
If you want to put a formula in the cell then it has to
take an action. Otherwise you could do something like this: If Range("DX11").Value < Range("B11").Value And Range ("G11").Value = "" Then Range("G11:CX298").Value = Range("$DZ11").Value End If tod -----Original Message----- Hi I'm using the following formula in a routine: Range("G11:CX298").Formula = "=IF(AND ($DX11<$B11,$G11="".""),$DZ11)" If the criteria = true then it placecs the value of $DZ11 which is want I want. What do I put in for the false part of the statement if I want to take no action? I don't want to clear or change the contents at all if the condition is false. Thanks --- Message posted from http://www.ExcelForum.com/ . |
If statement in VBA
Once you put the formula in, it overwrites whatever was there. If you just
want the cell to appear blank, then you would put in """" for the false condition. If you mean the cell already contains something which you want to retain, then you can't do that unless for each cell in the range, you build the formula individually for each cell, putting the current value as the False result. -- Regards, Tom Ogilvy "hotherps " wrote in message ... Hi I'm using the following formula in a routine: Range("G11:CX298").Formula = "=IF(AND($DX11<$B11,$G11="".""),$DZ11)" If the criteria = true then it placecs the value of $DZ11 which is want I want. What do I put in for the false part of the statement if I want to take no action? I don't want to clear or change the contents at all if the condition is false. Thanks --- Message posted from http://www.ExcelForum.com/ |
If statement in VBA
The formula as written checks each row and makes a determination for that
particular row against the values in that row. Your check only checks a single row and then imposes the formula on all rows, 11 to 298. I agree with you comment, but you would need to loop down the range and check the conditions for each row, posting a result particular to that row. -- Regards, Tom Ogilvy "Tod" wrote in message ... If you want to put a formula in the cell then it has to take an action. Otherwise you could do something like this: If Range("DX11").Value < Range("B11").Value And Range ("G11").Value = "" Then Range("G11:CX298").Value = Range("$DZ11").Value End If tod -----Original Message----- Hi I'm using the following formula in a routine: Range("G11:CX298").Formula = "=IF(AND ($DX11<$B11,$G11="".""),$DZ11)" If the criteria = true then it placecs the value of $DZ11 which is want I want. What do I put in for the false part of the statement if I want to take no action? I don't want to clear or change the contents at all if the condition is false. Thanks --- Message posted from http://www.ExcelForum.com/ . |
If statement in VBA
Thanks for the input guys, back to the drawing board..
-- Message posted from http://www.ExcelForum.com |
All times are GMT +1. The time now is 12:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com