![]() |
Testing 2 conditions on an IF statement
The following was already coded:
Dim srcProgramSummaryTemplateWs As Worksheet Set srcProgramSummaryTemplateWs = Sheets("@TemplateProgramSummary") I want to change the following €œIf€ statement to test for a second condition: Currently it states: If Target.Address = "$K$1" Then I would also like to test that the ActiveSheet < srcProgramSummaryTemplateWs Neither of these work: If Target.Address = "$K$1" & ActiveSheet < srcProgramSummaryTemplateWs Then If Target.Address = "$K$1" And ActiveSheet < srcProgramSummaryTemplateWs Then What is the correct context... |
Testing 2 conditions on an IF statement
You have objects and reference to boject won't work in terms of = or < Try
this If Target.Address = "$K$1" And ActiveSheet.name < srcProgramSummaryTemplateWs.Name -- HTH... Jim Thomlinson "CRayF" wrote: The following was already coded: Dim srcProgramSummaryTemplateWs As Worksheet Set srcProgramSummaryTemplateWs = Sheets("@TemplateProgramSummary") I want to change the following €œIf€ statement to test for a second condition: Currently it states: If Target.Address = "$K$1" Then I would also like to test that the ActiveSheet < srcProgramSummaryTemplateWs Neither of these work: If Target.Address = "$K$1" & ActiveSheet < srcProgramSummaryTemplateWs Then If Target.Address = "$K$1" And ActiveSheet < srcProgramSummaryTemplateWs Then What is the correct context... |
Testing 2 conditions on an IF statement
Hi CRayF,
To render the code functional, try: If Target.Address = "$K$1" And ActiveSheet.Name < srcProgramSummaryTemplateWs.Name Then However, if this code is not part of an event procedure, then Target should probably be replaced with a range expression - possibly, ActiveCell. If the code forms part of a worksheet event procedure, then the active sheet will be the sheet holding the code, so it should be unnecessary to include a sheet identification condition. If the code forms part of a Workbook sheet event, the reference to Activesheet can be replaced with an assignment to the event's sh argument. If you need further assistance, it would be helpful if you could indicate if you are working with an event procedure and where the code is placed. --- Regards, Norman "CRayF" wrote in message ... The following was already coded: Dim srcProgramSummaryTemplateWs As Worksheet Set srcProgramSummaryTemplateWs = Sheets("@TemplateProgramSummary") I want to change the following "If" statement to test for a second condition: Currently it states: If Target.Address = "$K$1" Then I would also like to test that the ActiveSheet < srcProgramSummaryTemplateWs Neither of these work: If Target.Address = "$K$1" & ActiveSheet < srcProgramSummaryTemplateWs Then If Target.Address = "$K$1" And ActiveSheet < srcProgramSummaryTemplateWs Then What is the correct context... |
Testing 2 conditions on an IF statement
many thanks
|
Testing 2 conditions on an IF statement
thanks again,
All works "Norman Jones" wrote: Hi CRayF, To render the code functional, try: If Target.Address = "$K$1" And ActiveSheet.Name < srcProgramSummaryTemplateWs.Name Then However, if this code is not part of an event procedure, then Target should probably be replaced with a range expression - possibly, ActiveCell. If the code forms part of a worksheet event procedure, then the active sheet will be the sheet holding the code, so it should be unnecessary to include a sheet identification condition. If the code forms part of a Workbook sheet event, the reference to Activesheet can be replaced with an assignment to the event's sh argument. If you need further assistance, it would be helpful if you could indicate if you are working with an event procedure and where the code is placed. --- Regards, Norman "CRayF" wrote in message ... The following was already coded: Dim srcProgramSummaryTemplateWs As Worksheet Set srcProgramSummaryTemplateWs = Sheets("@TemplateProgramSummary") I want to change the following "If" statement to test for a second condition: Currently it states: If Target.Address = "$K$1" Then I would also like to test that the ActiveSheet < srcProgramSummaryTemplateWs Neither of these work: If Target.Address = "$K$1" & ActiveSheet < srcProgramSummaryTemplateWs Then If Target.Address = "$K$1" And ActiveSheet < srcProgramSummaryTemplateWs Then What is the correct context... |
All times are GMT +1. The time now is 12:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com