ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help writing formula (https://www.excelbanter.com/excel-programming/326838-help-writing-formula.html)

Ryan Proudfit

help writing formula
 
The current formula residing in about 200 cells is

='Daily N '!AN13

I'm trying to write a macro that will change that formula to

=IF(OR(B9=6,B9=7),"",'Daily N '!AN13)

Here is my code

ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" & ActiveCell.Row &
"=7),""," & strHoldFormula & ")"

My problem is

"=7),"","

Since quotes are used to identify the beginning and end of a text string
within a formula, how do you use quotes within a formula to tell Excel to
display nothing if a condition is true?

--
Ryan Proudfit

Chip Pearson

help writing formula
 
To include a " character in a VBA string, use two " characters.
E.g.,

ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" & _
ActiveCell.Row & "=7),""""," & strHoldFormula & ")"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Ryan Proudfit" wrote in
message
...
The current formula residing in about 200 cells is

='Daily N '!AN13

I'm trying to write a macro that will change that formula to

=IF(OR(B9=6,B9=7),"",'Daily N '!AN13)

Here is my code

ActiveCell.Formula = "=IF(OR(B" & ActiveCell.Row & "=6,B" &
ActiveCell.Row &
"=7),""," & strHoldFormula & ")"

My problem is

"=7),"","

Since quotes are used to identify the beginning and end of a
text string
within a formula, how do you use quotes within a formula to
tell Excel to
display nothing if a condition is true?

--
Ryan Proudfit





All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com