ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Entering Formula with "" within it (https://www.excelbanter.com/excel-programming/320590-entering-formula-within.html)

Ron McCormick[_6_]

Entering Formula with "" within it
 
I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.
--
TIA
Ron

Edgar Thoemmes[_4_]

Entering Formula with "" within it
 
Hi

Try using =IF(Range1= """",Range2, Range1)

HTH


"Ron McCormick" wrote:

I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.
--
TIA
Ron


Bob Phillips[_6_]

Entering Formula with "" within it
 
Ron,

You need a pair

ActiveCell.Formula = "=IF(Range1= " & Chr(34) & Chr(34)& " ,Range2,Range1)"

or enter directly

ActiveCell.Formula = "=IF(Range1= """" ,Range2,Range1)"

or create a variable

sQuotes = Chr(34) & Chr(34)

ActiveCell.Formula = "=IF(Range1= " & sQuotes & " ,Range2,Range1)"

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ron McCormick" wrote in message
...
I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.
--
TIA
Ron




Dana DeLouis[_3_]

Entering Formula with "" within it
 
Just an alternative...

ActiveCell.Formula = "=IF(ISBLANK(Range1),Range2, Range1)"

--
Dana DeLouis
Win XP & Office 2003


"Ron McCormick" wrote in message
...
I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.
--
TIA
Ron





Bob Phillips[_6_]

Entering Formula with "" within it
 
But be aware (Ron that is) this formula returns False if there is another
formula such as =IF(cond,val,"") in Range1 whereas Range1="" returns True.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Dana DeLouis" wrote in message
...
Just an alternative...

ActiveCell.Formula = "=IF(ISBLANK(Range1),Range2, Range1)"

--
Dana DeLouis
Win XP & Office 2003


"Ron McCormick" wrote in message
...
I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.
--
TIA
Ron







Tushar Mehta

Entering Formula with "" within it
 
A technique that I routinely use is to turn on the macro recorder and
enter the formula in a cell. Turn off the recorder and XL will give
you the correct VBA code! :)

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , "=?
Utf-8?B?Um9uIE1jQ29ybWljaw==?="
says...
I am trying to write the appropriate code to enter a formula along the
following lines into a particular cell in a worksheet.

=IF(Range1= "",Range2, Range1)

I've been advised that I should use coded version of the quotes
incorporating Chr (34) - something like:

strQuote = Chr(34)
ActiveCell.Formula = "=IF(Range1= "& Chr(34) &" ,Range2,Range1)"

but I can't seem to get the syntax quite right.

Any help would be appreciated.



All times are GMT +1. The time now is 04:42 PM.

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