Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Pass on cell address to an UDF?

Is it possible to pass on the cell, in which an UDF is located, to the UDF
itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

....and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Pass on cell address to an UDF?

Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function






--
Steve

"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to the UDF
itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Pass on cell address to an UDF?

AltaEgo wrote:
Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function



Thanks, but that's the whole point: I was kind of hoping to be able to avoid
the ADDRESS(ROW(),COLUMN()), and just use =CELLTELL().

I was hoping that VBA had a way of 'reading' what cell the function was
located in?

Actually, just lige =ROW()
Somehow that function must be able to 'read' what cell it is located in?

Anyone know how to do this?


TIA,













"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to
the UDF itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Pass on cell address to an UDF?

Something like this ?

Function CellTell()
If Application.Caller.Address(False, False) = "C4" Then
CellTell = "Explosive"
Else
CellTell = "Harmless"
End If
End Function

Tim


"Charlotte E" <@ wrote in message
...
AltaEgo wrote:
Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function



Thanks, but that's the whole point: I was kind of hoping to be able to
avoid the ADDRESS(ROW(),COLUMN()), and just use =CELLTELL().

I was hoping that VBA had a way of 'reading' what cell the function was
located in?

Actually, just lige =ROW()
Somehow that function must be able to 'read' what cell it is located in?

Anyone know how to do this?


TIA,













"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to
the UDF itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Pass on cell address to an UDF?

Try this UDF...

Function CellTell()
CellTell = Application.Caller.Address
End Function

This returns an absolute address. If you want the ability to specify the
absolute/relative addressing mode, then here is a more general function...

Function CellTell(Optional ColAbsolute = True, Optional RowAbsolute = True)
CellTell = Application.Caller.Address(RowAbsolute, ColAbsolute)
End Function

So, if you wanted a fully relative address, you would use this UDF call...

=CellTell(FALSE,FALSE)

--
Rick (MVP - Excel)


"Charlotte E" <@ wrote in message
...
AltaEgo wrote:
Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function



Thanks, but that's the whole point: I was kind of hoping to be able to
avoid the ADDRESS(ROW(),COLUMN()), and just use =CELLTELL().

I was hoping that VBA had a way of 'reading' what cell the function was
located in?

Actually, just lige =ROW()
Somehow that function must be able to 'read' what cell it is located in?

Anyone know how to do this?


TIA,













"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to
the UDF itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Pass on cell address to an UDF?

I think I misread what you were looking to do... it looks like Tim's
response may be what you were after.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Try this UDF...

Function CellTell()
CellTell = Application.Caller.Address
End Function

This returns an absolute address. If you want the ability to specify the
absolute/relative addressing mode, then here is a more general function...

Function CellTell(Optional ColAbsolute = True, Optional RowAbsolute =
True)
CellTell = Application.Caller.Address(RowAbsolute, ColAbsolute)
End Function

So, if you wanted a fully relative address, you would use this UDF call...

=CellTell(FALSE,FALSE)

--
Rick (MVP - Excel)


"Charlotte E" <@ wrote in message
...
AltaEgo wrote:
Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function



Thanks, but that's the whole point: I was kind of hoping to be able to
avoid the ADDRESS(ROW(),COLUMN()), and just use =CELLTELL().

I was hoping that VBA had a way of 'reading' what cell the function was
located in?

Actually, just lige =ROW()
Somehow that function must be able to 'read' what cell it is located in?

Anyone know how to do this?


TIA,













"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to
the UDF itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Pass on cell address to an UDF?

Sorry for a late reply (out playing flag-football all day :-)

Thanks, Tim - that's excately what I was looking for :-)



Tim Williams wrote:
Something like this ?

Function CellTell()
If Application.Caller.Address(False, False) = "C4" Then
CellTell = "Explosive"
Else
CellTell = "Harmless"
End If
End Function

Tim


"Charlotte E" <@ wrote in message
...
AltaEgo wrote:
Using inbuilt functions in cells:

=IF(ADDRESS(ROW(),COLUMN())="$C$4","Explosive Cell","Harmless")

Expand on this and pass some parameters if you need it in a UDF:

Function CELLTELL(addr)
'use this way in cell
' =CELLTELL(ADDRESS(ROW(),COLUMN()))

CELLTELL = "Harmless cell"
If addr = "$C$4" Then CELLTELL = "Explosive cell"

End Function



Thanks, but that's the whole point: I was kind of hoping to be able
to avoid the ADDRESS(ROW(),COLUMN()), and just use =CELLTELL().

I was hoping that VBA had a way of 'reading' what cell the function
was located in?

Actually, just lige =ROW()
Somehow that function must be able to 'read' what cell it is located
in? Anyone know how to do this?


TIA,













"Charlotte E" <@ wrote in message
...
Is it possible to pass on the cell, in which an UDF is located, to
the UDF itself?


Example:

In cell C4, I have an UDF, like:

=CELLTELL()

...and the UDF could return something like:

Function CELLTELL()

If Celladdress = "C4" Then
CELLTELL = "Explosive cell!"
Else
CELLTELL = "Harmless cell"
End If

End Function


Hope you get the picture...


Thanks,



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
Pass a cell address - Modify interior font CarlS Excel Programming 4 June 29th 08 05:32 AM
Pass IE web address to Excel grove Excel Programming 2 April 10th 08 01:05 PM
Pass Cell Address to OFFSET ExcelGuy555 Excel Worksheet Functions 3 August 18th 07 07:42 AM
Pass a string to an address Robert H Excel Programming 3 February 25th 07 02:18 PM
How to pass address(es) as parameters Pat Excel Programming 12 May 22nd 06 03:15 AM


All times are GMT +1. The time now is 10:09 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"