Thread: UDF
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
incre-d[_2_] incre-d[_2_] is offline
external usenet poster
 
Posts: 14
Default UDF

Function myCell(Optional Cell, optional Style = 1)
Application.Volatile
If IsMissing(Cell) Then
myCell = Application.Caller. _
Address(rowabsolute:=False, _
columnabsolute:=False)
Else

columnStyle = (Style Mod 2 = 0)
rowStyle = Style 2

myCell = Cell. _
Address(rowabsolute:=rowStyle, _
columnabsolute:=columnStyle)
End If
End Function


"Hans Knudsen" wrote:

A long time ago someone gave me this UDF which has been of great value to
me.

Function myCell(Optional Cell)
Application.Volatile
If IsMissing(Cell) Then
myCell = Application.Caller. _
Address(rowabsolute:=False, _
columnabsolute:=False)
Else
myCell = Cell. _
Address(rowabsolute:=False, _
columnabsolute:=False)
End If
End Function

If I type for example: =mycell(K353) returns K353. If I type =mycell($K$353)
it still returns K353.

Question:
What should the UDF look like if I want:

=mycell(K353;1) should return K353
=mycell(K353;2) should return $K353
=mycell(K353;3) should return K$353
=mycell(K353;4) should return $K$353

Hans Knudsen