Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Null value in excel

Hi everyone:

I am using the Strcomp to compare the value of two cells in excel. I was
wondering is it possible for a cell to ever be Null? In other words, do I
need to worry about it in the returned value of Strcomp, or just look
for -1, 0, 1. Thanks for all your help.

Bob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Null value in excel

A cell can have a Null value, but StrComp handles this situation.
Nuill is less that any other value, so

Debug.Print StrComp(Range("A1").Value, Range("A2").Value)

will reutrn -1 is A1 is null (and A2 is not).

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
The San Diego Project Group, LLC
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)


On Wed, 24 Sep 2008 13:14:00 -0700, "Bob" wrote:

Hi everyone:

I am using the Strcomp to compare the value of two cells in excel. I was
wondering is it possible for a cell to ever be Null? In other words, do I
need to worry about it in the returned value of Strcomp, or just look
for -1, 0, 1. Thanks for all your help.

Bob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Null value in excel

In cells you can have #NULL! error, and as with all error values StrComp
will fail with a mismatch error

Range("A1").Value = CVErr(xlErrNull)
x = StrComp(Range("A1").Value, "abc")

might be worth doing something like the following first
If VarType(Range("A1").Value) < vbError Then

Regards,
Peter T




"Bob" wrote in message
...
Hi everyone:

I am using the Strcomp to compare the value of two cells in excel. I was
wondering is it possible for a cell to ever be Null? In other words, do I
need to worry about it in the returned value of Strcomp, or just look
for -1, 0, 1. Thanks for all your help.

Bob




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Null value in excel

I may be misunderstood, but i think a Cell can't have Null if Null
doesn't mean Null string. so, you don't need to worry about it as long
as comparing the value of two Cells. My idea based on the code below.

Sub nulltest()
Dim P

P = Null
ActiveCell = Null

If IsNull(P) Then
MsgBox "P is Null"
Else
MsgBox "P is not Null"
End If

If IsNull(ActiveCell) Then
MsgBox "ActiveCell is Null"
ElseIf IsEmpty(ActiveCell) Then
MsgBox "ActiveCell is Empty"
End If

ActiveCell = "" ' Or ActiveCell=Empty

If IsNull(ActiveCell) Then
MsgBox "Activecell is Null"
ElseIf IsEmpty(ActiveCell) Then
MsgBox "ActiveCell is Empty"
ElseIf ActiveCell = "" Then
MsgBox "ActiveCell is """""
Else
MsgBox "ActiveCell is Unkown"
End If
ActiveCell = "'"

If IsNull(ActiveCell) Then
MsgBox "ActiveCell is Null"
ElseIf IsEmpty(ActiveCell) Then
MsgBox "ActiveCell is Empty"
ElseIf ActiveCell = "" Then
MsgBox "ActiveCell is ""'""(Null string?)"
Else
MsgBox "ActiveCell is Unkown"
End If

End Sub

keiji

Bob wrote:
Hi everyone:

I am using the Strcomp to compare the value of two cells in excel. I was
wondering is it possible for a cell to ever be Null? In other words, do I
need to worry about it in the returned value of Strcomp, or just look
for -1, 0, 1. Thanks for all your help.

Bob


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Null value in excel

Thank you all.

Bob

"Bob" wrote in message
...
Hi everyone:

I am using the Strcomp to compare the value of two cells in excel. I was
wondering is it possible for a cell to ever be Null? In other words, do I
need to worry about it in the returned value of Strcomp, or just look
for -1, 0, 1. Thanks for all your help.

Bob






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
Failed to save table attributes of (null) into (null). Luca Brasi Excel Discussion (Misc queries) 2 February 4th 09 04:30 PM
Null exist in Excel clara Excel Programming 2 April 19th 07 03:32 PM
Null, "null", vbNull, vbNullString, vbEmpty [email protected] Excel Programming 2 July 25th 06 01:28 PM
Createobject returns null in Excel [email protected] Excel Discussion (Misc queries) 1 March 27th 06 04:04 AM
VB excel Null values !! Please help me !! Aruna Tennakoon Excel Programming 4 April 29th 04 10:13 AM


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

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"