![]() |
Excel IF function help
Hello-
I need to write a statement similar to: IF (F2 = 4 AND J2 = 4) then AA2 = "Northwest" else AA2 leave at whatever value is currently there (no change) IF (F2 <=2 AND J2 =4) then AA2 = "Northeast" else AA2 leave at whatever value is currently there (no change) How do I do this in excel? Thank you so much |
Excel IF function help
This can not be done with a formula, unless it resides in AA2. But then it
can't leave whatever AA2 value it has, because AA2 contains this formula, not a value. So you need a VBA macro to do this. My question is, before writing a suggestion: When do you want this action to happen, and how does the values change in F2 and J2 ? Best wishes Harald "DTTODGG" skrev i melding ... Hello- I need to write a statement similar to: IF (F2 = 4 AND J2 = 4) then AA2 = "Northwest" else AA2 leave at whatever value is currently there (no change) IF (F2 <=2 AND J2 =4) then AA2 = "Northeast" else AA2 leave at whatever value is currently there (no change) How do I do this in excel? Thank you so much |
Excel IF function help
Thank you for your reply-
When do I want this action to happen? Whatever is easiest - at open or with a button or key. I have a spreadsheet that is filled out. I need to make a matrix with nine conditions. I have 2 columns with this data. It gets updated once a month or so. I wrote an earlier question to this group (search on "Need a MATRIX diagram") that explains what I wanted to do. It didn't look do-able, so I'm trying a different tack. I'm needing the correlation between the 2 columns. I hope this explains things - again I really appreciate your help. "Harald Staff" wrote: This can not be done with a formula, unless it resides in AA2. But then it can't leave whatever AA2 value it has, because AA2 contains this formula, not a value. So you need a VBA macro to do this. My question is, before writing a suggestion: When do you want this action to happen, and how does the values change in F2 and J2 ? Best wishes Harald "DTTODGG" skrev i melding ... Hello- I need to write a statement similar to: IF (F2 = 4 AND J2 = 4) then AA2 = "Northwest" else AA2 leave at whatever value is currently there (no change) IF (F2 <=2 AND J2 =4) then AA2 = "Northeast" else AA2 leave at whatever value is currently there (no change) How do I do this in excel? Thank you so much |
Excel IF function help
I see.
I beluieve I'd approach that task with a formula like this in a spare column: =CHOOSE(F2,"C","C","B","A","A")&CHOOSE(J2,"C","C", "B","A","A") it says C for 1 and 2, B for 3 and A for 4 and 5, and it's returning AA, CB, AB, ... suitable for pivoting and subtotalling. As for the VBA macro solution in mention, open the VB editor (Alt F11 or similar), insert a module by menu Insert - Module. Paste this text into the module: Sub LoopSample() Dim R As Long 'row number For R = 2 To 500 If Cells(R, 6).Value = 4 Then If Cells(R, 10) = 4 Then Cells(R, 27).Value = "Northwest" End If End If Next R End Sub Return to Excel and run it from the Tools - Macro - Run menu. Or put some object onto your worksheet either from the Forms toolbar or the Drawing toolbar, then rightclick it, select "assign macro" and assign the macro LoopSample. Now the code runs when you click this object. HTH. Best wishes Harald "DTTODGG" skrev i melding ... Thank you for your reply- When do I want this action to happen? Whatever is easiest - at open or with a button or key. I have a spreadsheet that is filled out. I need to make a matrix with nine conditions. I have 2 columns with this data. It gets updated once a month or so. I wrote an earlier question to this group (search on "Need a MATRIX diagram") that explains what I wanted to do. It didn't look do-able, so I'm trying a different tack. I'm needing the correlation between the 2 columns. I hope this explains things - again I really appreciate your help. "Harald Staff" wrote: This can not be done with a formula, unless it resides in AA2. But then it can't leave whatever AA2 value it has, because AA2 contains this formula, not a value. So you need a VBA macro to do this. My question is, before writing a suggestion: When do you want this action to happen, and how does the values change in F2 and J2 ? Best wishes Harald "DTTODGG" skrev i melding ... Hello- I need to write a statement similar to: IF (F2 = 4 AND J2 = 4) then AA2 = "Northwest" else AA2 leave at whatever value is currently there (no change) IF (F2 <=2 AND J2 =4) then AA2 = "Northeast" else AA2 leave at whatever value is currently there (no change) How do I do this in excel? Thank you so much |
Excel IF function help
Harold - thank you SO much for your help. The solution worked beautifully and
saved me much time. "Harald Staff" wrote: I see. I beluieve I'd approach that task with a formula like this in a spare column: =CHOOSE(F2,"C","C","B","A","A")&CHOOSE(J2,"C","C", "B","A","A") it says C for 1 and 2, B for 3 and A for 4 and 5, and it's returning AA, CB, AB, ... suitable for pivoting and subtotalling. As for the VBA macro solution in mention, open the VB editor (Alt F11 or similar), insert a module by menu Insert - Module. Paste this text into the module: Sub LoopSample() Dim R As Long 'row number For R = 2 To 500 If Cells(R, 6).Value = 4 Then If Cells(R, 10) = 4 Then Cells(R, 27).Value = "Northwest" End If End If Next R End Sub Return to Excel and run it from the Tools - Macro - Run menu. Or put some object onto your worksheet either from the Forms toolbar or the Drawing toolbar, then rightclick it, select "assign macro" and assign the macro LoopSample. Now the code runs when you click this object. HTH. Best wishes Harald "DTTODGG" skrev i melding ... Thank you for your reply- When do I want this action to happen? Whatever is easiest - at open or with a button or key. I have a spreadsheet that is filled out. I need to make a matrix with nine conditions. I have 2 columns with this data. It gets updated once a month or so. I wrote an earlier question to this group (search on "Need a MATRIX diagram") that explains what I wanted to do. It didn't look do-able, so I'm trying a different tack. I'm needing the correlation between the 2 columns. I hope this explains things - again I really appreciate your help. "Harald Staff" wrote: This can not be done with a formula, unless it resides in AA2. But then it can't leave whatever AA2 value it has, because AA2 contains this formula, not a value. So you need a VBA macro to do this. My question is, before writing a suggestion: When do you want this action to happen, and how does the values change in F2 and J2 ? Best wishes Harald "DTTODGG" skrev i melding ... Hello- I need to write a statement similar to: IF (F2 = 4 AND J2 = 4) then AA2 = "Northwest" else AA2 leave at whatever value is currently there (no change) IF (F2 <=2 AND J2 =4) then AA2 = "Northeast" else AA2 leave at whatever value is currently there (no change) How do I do this in excel? Thank you so much |
All times are GMT +1. The time now is 05:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com