Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 43
Default IF statement in macro

This is the formual:
=IF(AND(L3="Y", M3="Y", N3="Y"), "Y", "N")

I am having a hard time to add it in my existing macro.


********
FYI, I have an OR formula in my macron that works very well:
=IF(OR(E3="B", E3="C", E3="E"), "Y", "N")

In the macro:
..Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Any suggestion?

Thanks,


--
Aline

--
Aline
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,069
Default IF statement in macro

Try something like

ActiveCell.Formula = "=IF(AND(L3=""Y"", M3=""Y"", N3=""Y""), ""Y"", ""N"")"

Hope this helps,

Hutch

"Aline" wrote:

This is the formual:
=IF(AND(L3="Y", M3="Y", N3="Y"), "Y", "N")

I am having a hard time to add it in my existing macro.


********
FYI, I have an OR formula in my macron that works very well:
=IF(OR(E3="B", E3="C", E3="E"), "Y", "N")

In the macro:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Any suggestion?

Thanks,


--
Aline

--
Aline

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 43
Default IF statement in macro

Hi Tom,

Do you know can I modify it so it will automatically run the formula for the
rest of rows in the macro? Similar to another formula I've already had:
..Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Thanks,
Aline



--
Aline


"Tom Hutchins" wrote:

Try something like

ActiveCell.Formula = "=IF(AND(L3=""Y"", M3=""Y"", N3=""Y""), ""Y"", ""N"")"

Hope this helps,

Hutch

"Aline" wrote:

This is the formual:
=IF(AND(L3="Y", M3="Y", N3="Y"), "Y", "N")

I am having a hard time to add it in my existing macro.


********
FYI, I have an OR formula in my macron that works very well:
=IF(OR(E3="B", E3="C", E3="E"), "Y", "N")

In the macro:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Any suggestion?

Thanks,


--
Aline

--
Aline

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,069
Default IF statement in macro

To do that, it's better to use R1C1-type cell addresses in the formulas added
to your worksheet from your macro. Assuming you have assigned a value to
LastRow, as in your other example, and that you want to enter the formulas in
column E (starting in row 3), try this:

With ActiveSheet
..Range("E3:E" & LastRow).Formula _
= "=IF(AND(RC12=""Y"", RC13=""Y"", RC14=""Y""), ""Y"", ""N"")"
End With

Hope this helps,

Hutch

"Aline" wrote:

Hi Tom,

Do you know can I modify it so it will automatically run the formula for the
rest of rows in the macro? Similar to another formula I've already had:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Thanks,
Aline



--
Aline


"Tom Hutchins" wrote:

Try something like

ActiveCell.Formula = "=IF(AND(L3=""Y"", M3=""Y"", N3=""Y""), ""Y"", ""N"")"

Hope this helps,

Hutch

"Aline" wrote:

This is the formual:
=IF(AND(L3="Y", M3="Y", N3="Y"), "Y", "N")

I am having a hard time to add it in my existing macro.


********
FYI, I have an OR formula in my macron that works very well:
=IF(OR(E3="B", E3="C", E3="E"), "Y", "N")

In the macro:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Any suggestion?

Thanks,


--
Aline

--
Aline

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 43
Default IF statement in macro

Hi Tom,

It works! Thanks a lot. You're the best.

Aline
--
Aline


"Tom Hutchins" wrote:

To do that, it's better to use R1C1-type cell addresses in the formulas added
to your worksheet from your macro. Assuming you have assigned a value to
LastRow, as in your other example, and that you want to enter the formulas in
column E (starting in row 3), try this:

With ActiveSheet
.Range("E3:E" & LastRow).Formula _
= "=IF(AND(RC12=""Y"", RC13=""Y"", RC14=""Y""), ""Y"", ""N"")"
End With

Hope this helps,

Hutch

"Aline" wrote:

Hi Tom,

Do you know can I modify it so it will automatically run the formula for the
rest of rows in the macro? Similar to another formula I've already had:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Thanks,
Aline



--
Aline


"Tom Hutchins" wrote:

Try something like

ActiveCell.Formula = "=IF(AND(L3=""Y"", M3=""Y"", N3=""Y""), ""Y"", ""N"")"

Hope this helps,

Hutch

"Aline" wrote:

This is the formual:
=IF(AND(L3="Y", M3="Y", N3="Y"), "Y", "N")

I am having a hard time to add it in my existing macro.


********
FYI, I have an OR formula in my macron that works very well:
=IF(OR(E3="B", E3="C", E3="E"), "Y", "N")

In the macro:
.Range("L3:L" & LastRow).Formula _
= "=IF(E3=""B"", ""Y"", IF(OR(E3=""C""," _
& "E3=""E""), ""Y"", ""N""))"

Any suggestion?

Thanks,


--
Aline

--
Aline

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro if and / or statement orquidea Excel Discussion (Misc queries) 4 April 4th 23 10:27 AM
If Statement to run a macro Secret Squirrel Excel Discussion (Misc queries) 4 July 15th 08 03:43 PM
If statement in macro punter Excel Discussion (Misc queries) 3 June 20th 06 12:23 PM
can i use an IF Statement to run a macro? Davidrowland88 Excel Worksheet Functions 2 February 11th 05 12:45 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"