ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format code returning error (https://www.excelbanter.com/excel-programming/401290-format-code-returning-error.html)

Mike K

Format code returning error
 
Oh Wise Ones,

I have a sheet that inserts a row and formats some cells including this line
that works:

Worksheets("Open Red Tags").Range("Q4").Formula = "=IF(J4=$K$1,H4,"""")"

but when I tried to format R4 like below I get an error as soon as I enter it:
Unexpected end of statement

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4="A",H4,"""")"

Then I tried this that didn't work:

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4=A,H4,"""")"

What am I doing wrong? They seem so similar.

Mike

Dave Peterson

Format code returning error
 
You doubled up those double quotes in the last portion of the formula:
Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4="A",H4,"""")"

But don't forget to do the same with the double quotes around A.
Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4=""A"",H4,"""")"



Mike K wrote:

Oh Wise Ones,

I have a sheet that inserts a row and formats some cells including this line
that works:

Worksheets("Open Red Tags").Range("Q4").Formula = "=IF(J4=$K$1,H4,"""")"

but when I tried to format R4 like below I get an error as soon as I enter it:
Unexpected end of statement

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4="A",H4,"""")"

Then I tried this that didn't work:

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4=A,H4,"""")"

What am I doing wrong? They seem so similar.

Mike


--

Dave Peterson

Mike K

Format code returning error
 
Thanks Dave.


"Dave Peterson" wrote:

You doubled up those double quotes in the last portion of the formula:
Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4="A",H4,"""")"

But don't forget to do the same with the double quotes around A.
Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4=""A"",H4,"""")"



Mike K wrote:

Oh Wise Ones,

I have a sheet that inserts a row and formats some cells including this line
that works:

Worksheets("Open Red Tags").Range("Q4").Formula = "=IF(J4=$K$1,H4,"""")"

but when I tried to format R4 like below I get an error as soon as I enter it:
Unexpected end of statement

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4="A",H4,"""")"

Then I tried this that didn't work:

Worksheets("Open Red Tags").Range("R4").Formula = "=IF(F4=A,H4,"""")"

What am I doing wrong? They seem so similar.

Mike


--

Dave Peterson



All times are GMT +1. The time now is 01:40 PM.

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