Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
This works:
If ActiveChart Is Nothing Then **code** End If But what I need is the reverse of this, as in ... If ActiveChart Is 'Not' Nothing, or If ActiveChart is 'Something' Of course neither of these work. How do I do this? Art |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
If Not ActiveChart Is Nothing Then
-- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "ArthurJ" wrote in message ... This works: If ActiveChart Is Nothing Then **code** End If But what I need is the reverse of this, as in ... If ActiveChart Is 'Not' Nothing, or If ActiveChart is 'Something' Of course neither of these work. How do I do this? Art |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
if not activechart is nothing then
or if not (activechart is nothing) then or I'd use: if activechart is nothing then 'do it's nothing stuff else 'do if it's "something" stuff end if I find the last one much easier to wrap my brain around (I don't like double negatives <bg). Well, except in =sumproduct()'s. (An excel joke!) ArthurJ wrote: This works: If ActiveChart Is Nothing Then **code** End If But what I need is the reverse of this, as in ... If ActiveChart Is 'Not' Nothing, or If ActiveChart is 'Something' Of course neither of these work. How do I do this? Art -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
Thank you Bob and Dave. Just what I needed.
Dave, the reason I didn't use the following structure .... if activechart is nothing then 'do it's nothing stuff else 'do if it's "something" stuff end if ..... is that the 'nothing stuff' is many lines of code while the 'something stuff' is zero lines. That makes the If-Then-Else statement really hard to read! Art |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
I don't think this looks bad:
if activechart is nothing then 'your lots of code here end if === and I use this all the time: if something = true then 'do nothing else a bunch of code here end if I actually put the characters "'Do nothing" in the code--for readability sake only. Kind of like "NEXT SENTENCE" in COBOL. ArthurJ wrote: Thank you Bob and Dave. Just what I needed. Dave, the reason I didn't use the following structure .... if activechart is nothing then 'do it's nothing stuff else 'do if it's "something" stuff end if .... is that the 'nothing stuff' is many lines of code while the 'something stuff' is zero lines. That makes the If-Then-Else statement really hard to read! Art -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Not Nothing
'I thought my question was resolved, and it is, well, sort of ....
'Can anyone explain the peculiar behavior of the second macro? Sub testDeactivate1() 'Crashes if there is no active chart. Worksheets(2).Activate ActiveChart.Deselect End Sub Sub testDeActivate2() 'This sub does not crash and the end result is that there 'is no active chart. 'But the odd thing is that if there is 'NOTHING selected (including cells) then the macro branches through 'the Then part of the If statement (even though there is no 'active chart). Yet it does not crash! 'Contrast this behavior with the other sub, which crashes if there is 'no active chart. 'If there is a cell range selected, the macro branches through 'the Else portion of the routine. Worksheets(2).Activate If Not (ActiveChart Is Nothing) Then MsgBox ("There IS an active chart") ActiveChart.Deselect MsgBox ("Not any more!") Else MsgBox ("There is NOT an active chart.") End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|