ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Code for "" empty cell (https://www.excelbanter.com/excel-discussion-misc-queries/248234-vba-code-empty-cell.html)

ManhattanRebel

VBA Code for "" empty cell
 
The following IF function works in Excel, but when I copy it into VBA so I
can excute it in a range it will not work.

Range("p6:p40").Formula = "=IF(C6="","",(P5+O6)-M6)"

I think VBA has a problem with "" meaning an empty cell.

Can someone tell me what I can substitute for "" so my formula will work in
VBA?


Jacob Skaria

VBA Code for "" empty cell
 
Try the below.. VBA recognizes double double quote as a single double quote

Range("p6:p40").Formula = "=IF(C6="""","""",(P5+O6)-M6)"

If this post helps click Yes
---------------
Jacob Skaria


"ManhattanRebel" wrote:

The following IF function works in Excel, but when I copy it into VBA so I
can excute it in a range it will not work.

Range("p6:p40").Formula = "=IF(C6="","",(P5+O6)-M6)"

I think VBA has a problem with "" meaning an empty cell.

Can someone tell me what I can substitute for "" so my formula will work in
VBA?


ManhattanRebel

VBA Code for "" empty cell
 
Thank you...that solved the problem

"Jacob Skaria" wrote:

Try the below.. VBA recognizes double double quote as a single double quote

Range("p6:p40").Formula = "=IF(C6="""","""",(P5+O6)-M6)"

If this post helps click Yes
---------------
Jacob Skaria


"ManhattanRebel" wrote:

The following IF function works in Excel, but when I copy it into VBA so I
can excute it in a range it will not work.

Range("p6:p40").Formula = "=IF(C6="","",(P5+O6)-M6)"

I think VBA has a problem with "" meaning an empty cell.

Can someone tell me what I can substitute for "" so my formula will work in
VBA?



All times are GMT +1. The time now is 06:55 PM.

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