# If Then Statement

This is a discussion on If Then Statement within the Excel Questions forums, part of the Question Forums category; Hi All, I have the following code which tests to see if the value in column J is a "Y": ...

1. Hi All, I have the following code which tests to see if the value in column J is a "Y":

For x = 7 To Counter

Range("E" & x).Formula = "=if(\$J\$" & x & "=Y,\$D\$" & x & " * .025,0)"

Next x

I am not sure how to show the "Y" with quotes in the formula. Without the quotes it bombs. I tried using the single ticks 'Y' but this did not work either. Any help would be appreciated.

Regards,
Bill Mahoney

2. On 2002-08-30 09:10, Madingo wrote:
Hi All, I have the following code which tests to see if the value in column J is a "Y":

For x = 7 To Counter

Range("E" & x).Formula = "=if(\$J\$" & x & "=Y,\$D\$" & x & " * .025,0)"

Next x

I am not sure how to show the "Y" with quotes in the formula. Without the quotes it bombs. I tried using the single ticks 'Y' but this did not work either. Any help would be appreciated.

Regards,
Bill Mahoney
Try this:

Range("E" & x).Formula = "=if(\$J\$" & x & "=""Y"",\$D\$" & x & " * .025,0)"

Or, you can do this:

Range("E" & x).Formula = "=if(\$J\$" & x & "=" & Chr(34) & "Y" & Chr(34) & ",\$D\$" & x & " * .025,0)"

Chr(34) is the double-quote.

HTH,

Russell

3. Thanks for the help.

Regards,
Bill Mahoney

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•