Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Testing 2 conditions on an IF statement

many thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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...



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default 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...






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
Testing for conditions with IF statement and AND function Joe[_13_] Excel Worksheet Functions 1 February 9th 09 06:07 PM
If Statement On Two Conditions RoadKill Excel Worksheet Functions 5 July 28th 08 06:57 PM
why can i use 3 conditions in SQL statement only? Tarek Excel Programming 2 August 17th 05 07:28 AM
Testing for Multiple Conditions Steve Excel Discussion (Misc queries) 2 July 20th 05 12:29 AM
testing more than one variable in an if statement Charles Excel Discussion (Misc queries) 3 February 22nd 05 06:46 PM


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

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

About Us

"It's about Microsoft Excel"