#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default IsMissing()

I had a question IsMissing Function and Ron Rosenfeld assisted on this.
He provided the following streamline of the code I was trying to run
==================
Sub foo()
Call OutputResult(Worksheets("output").Range("B1"))
End Sub
-------------------------
Sub OutputResult(Optional InCell As Range)

If IsMissing(InCell) Then
InCell.Value = 123
End If

End Sub
==========================
The problem I am encountering is that whether or not the call subroutine
call provides the optional range argument, the if IsMissing statement is
skipped Since the IsMissing function is passed a variant data type I am
wondering if a range is considered a variant. Is that the reason the
IsMissing() statement is always evaluating to TRUE.
Actually the statement I want to use is
--------------------------
If NOT IsMissing(InCell) Then
InCell.Value = 123
End If

so that when no range is passed the InCell.Value Statement is not executed.
Any assistance to get over this will be greatly appreciated.
Kuze

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IsMissing()


Use this instead

If Not InCell Is Nothing then


End I

--
Nick
-----------------------------------------------------------------------
Nicke's Profile: http://www.excelforum.com/member.php...nfo&userid=293
View this thread: http://www.excelforum.com/showthread.php?threadid=26959

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default IsMissing()

A range isn't a variant

Sub OutputResult(Optional InCell As Variant)

If Not IsMissing(InCell) Then
InCell.Value = 123
End If

End Sub

worked for me.

--
Regards,
Tom Ogilvy

"Kuzemdoo Dawuni" wrote in
message ...
I had a question IsMissing Function and Ron Rosenfeld assisted on

this.
He provided the following streamline of the code I was trying to run
==================
Sub foo()
Call OutputResult(Worksheets("output").Range("B1"))
End Sub
-------------------------
Sub OutputResult(Optional InCell As Range)

If IsMissing(InCell) Then
InCell.Value = 123
End If

End Sub
==========================
The problem I am encountering is that whether or not the call subroutine
call provides the optional range argument, the if IsMissing statement is
skipped Since the IsMissing function is passed a variant data type I am
wondering if a range is considered a variant. Is that the reason the
IsMissing() statement is always evaluating to TRUE.
Actually the statement I want to use is
--------------------------
If NOT IsMissing(InCell) Then
InCell.Value = 123
End If

so that when no range is passed the InCell.Value Statement is not

executed.
Any assistance to get over this will be greatly appreciated.
Kuze



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default IsMissing()

Did you try the Is Nothing test I suggested in my last post?



On Fri, 15 Oct 2004 08:19:09 -0700, Kuzemdoo Dawuni
wrote:

I had a question IsMissing Function and Ron Rosenfeld assisted on this.
He provided the following streamline of the code I was trying to run
==================
Sub foo()
Call OutputResult(Worksheets("output").Range("B1"))
End Sub
-------------------------
Sub OutputResult(Optional InCell As Range)

If IsMissing(InCell) Then
InCell.Value = 123
End If

End Sub
==========================
The problem I am encountering is that whether or not the call subroutine
call provides the optional range argument, the if IsMissing statement is
skipped Since the IsMissing function is passed a variant data type I am
wondering if a range is considered a variant. Is that the reason the
IsMissing() statement is always evaluating to TRUE.
Actually the statement I want to use is
--------------------------
If NOT IsMissing(InCell) Then
InCell.Value = 123
End If

so that when no range is passed the InCell.Value Statement is not executed.
Any assistance to get over this will be greatly appreciated.
Kuze


--ron
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
IsMissing() Kuzemdoo Dawuni Excel Programming 3 October 15th 04 03:19 AM


All times are GMT +1. The time now is 06:39 PM.

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"