Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RPC RPC is offline
external usenet poster
 
Posts: 6
Default How a function can return "Nothing" or "Empty"

Hello all,
I have a function that return certain value depending on calculations.
In certain conditions I would want to return a value so that receiving cell
behaves as if I would press Del-key, this is nothing is displayed and content
is empty.
I tried returning Null, but 0 is displayed in this case.
I tried returning "", but conditional formatting of the cell understand that
this is a value and then gives an undesired format.
Do anybody of you know how to solve this?
Any idea or suggestion will be welcome.
Thanks in advance and kind regards,
Raúl

(You can see here the function:

Public Function LastValue(iRowTitle As Long, _
FirstCell As Range, _
BlockSize As Long, ColInBlock As Long,
ColInBlock2 As Long) As Variant
Dim WS As Excel.Worksheet
Dim ThereIsData As Boolean
Dim i As Long
Dim RGBlock As Excel.Range
LastValue = Null '<<<<<<<========================= Value returned
when I cannot calculate the result

Set WS = FirstCell.Parent
ThereIsData = True
i = FirstCell.Column
Set RGBlock = Range(WS.Cells(FirstCell.Row, FirstCell.Column),
WS.Cells(FirstCell.Row, FirstCell.Column + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False

Do While ThereIsData
If RGBlock.Cells(1, ColInBlock) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock)
ElseIf RGBlock.Cells(1, ColInBlock2) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock2)
End If
Set RGBlock = Range(WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize),
WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False
Loop

End_Zone:
Exit Function

End Function
)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How a function can return "Nothing" or "Empty"

Excel doesn't have the equivalent of a Null.

Maybe you could change your conditional formatting rules or even return a unique
string and use that.

RPC wrote:

Hello all,
I have a function that return certain value depending on calculations.
In certain conditions I would want to return a value so that receiving cell
behaves as if I would press Del-key, this is nothing is displayed and content
is empty.
I tried returning Null, but 0 is displayed in this case.
I tried returning "", but conditional formatting of the cell understand that
this is a value and then gives an undesired format.
Do anybody of you know how to solve this?
Any idea or suggestion will be welcome.
Thanks in advance and kind regards,
Raúl

(You can see here the function:

Public Function LastValue(iRowTitle As Long, _
FirstCell As Range, _
BlockSize As Long, ColInBlock As Long,
ColInBlock2 As Long) As Variant
Dim WS As Excel.Worksheet
Dim ThereIsData As Boolean
Dim i As Long
Dim RGBlock As Excel.Range
LastValue = Null '<<<<<<<========================= Value returned
when I cannot calculate the result

Set WS = FirstCell.Parent
ThereIsData = True
i = FirstCell.Column
Set RGBlock = Range(WS.Cells(FirstCell.Row, FirstCell.Column),
WS.Cells(FirstCell.Row, FirstCell.Column + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False

Do While ThereIsData
If RGBlock.Cells(1, ColInBlock) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock)
ElseIf RGBlock.Cells(1, ColInBlock2) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock2)
End If
Set RGBlock = Range(WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize),
WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False
Loop

End_Zone:
Exit Function

End Function
)


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
RPC RPC is offline
external usenet poster
 
Posts: 6
Default How a function can return "Nothing" or "Empty"

This is what I thougth. It is a pity but....
Thanks for your answer.
Kind regards,
Raúl


"Dave Peterson" wrote:

Excel doesn't have the equivalent of a Null.

Maybe you could change your conditional formatting rules or even return a unique
string and use that.

RPC wrote:

Hello all,
I have a function that return certain value depending on calculations.
In certain conditions I would want to return a value so that receiving cell
behaves as if I would press Del-key, this is nothing is displayed and content
is empty.
I tried returning Null, but 0 is displayed in this case.
I tried returning "", but conditional formatting of the cell understand that
this is a value and then gives an undesired format.
Do anybody of you know how to solve this?
Any idea or suggestion will be welcome.
Thanks in advance and kind regards,
Raúl

(You can see here the function:

Public Function LastValue(iRowTitle As Long, _
FirstCell As Range, _
BlockSize As Long, ColInBlock As Long,
ColInBlock2 As Long) As Variant
Dim WS As Excel.Worksheet
Dim ThereIsData As Boolean
Dim i As Long
Dim RGBlock As Excel.Range
LastValue = Null '<<<<<<<========================= Value returned
when I cannot calculate the result

Set WS = FirstCell.Parent
ThereIsData = True
i = FirstCell.Column
Set RGBlock = Range(WS.Cells(FirstCell.Row, FirstCell.Column),
WS.Cells(FirstCell.Row, FirstCell.Column + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False

Do While ThereIsData
If RGBlock.Cells(1, ColInBlock) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock)
ElseIf RGBlock.Cells(1, ColInBlock2) < "" Then
LastValue = RGBlock.Cells(1, ColInBlock2)
End If
Set RGBlock = Range(WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize),
WS.Cells(RGBlock.Row, RGBlock.Column + BlockSize + BlockSize - 1))
If WS.Cells(iRowTitle, RGBlock.Column) = "" Then ThereIsData = False
Loop

End_Zone:
Exit Function

End Function
)


--

Dave Peterson

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Empty a cell if the values equal to "IN" , "MC" or "PP" YHT Excel Programming 1 December 28th 07 06:59 AM
function to return day in the form "Monday", "Tuesday" etc given . MTro Excel Worksheet Functions 2 October 3rd 07 09:49 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Can IF function return an empty cell? (not "") mtnw Excel Worksheet Functions 1 January 10th 07 11:01 PM


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

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"