Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do you get calling cell for custom function

I have written a custom function that returns database data to my
spreadsheet. The follwoing code snippet describesthe process. I test the
variable being passed in. If it is an object (cell range like A1:A3), I get
that address and process results based upon the values in those cells.

My question is, how do I get the address of the calling cell (the cell where
I entered the formula)? I want to test whether it is an array formula.

Public Function GetSqlData(ByVal ProcName As Variant) As Variant
Dim sProcName As Variant
If IsObject(ProcName) = True Then
Set xRange = ProcName
sProcName = GetValues(xRange)
Else
sProcName = ProcName
End If
GetSqlData = sProcName
End Function

Thanks,

Greg
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How do you get calling cell for custom function

As an example

MsgBox Application.Caller.Address


Gregory Cmar wrote:
I have written a custom function that returns database data to my
spreadsheet. The follwoing code snippet describesthe process. I test the
variable being passed in. If it is an object (cell range like A1:A3), I get
that address and process results based upon the values in those cells.

My question is, how do I get the address of the calling cell (the cell where
I entered the formula)? I want to test whether it is an array formula.

Public Function GetSqlData(ByVal ProcName As Variant) As Variant
Dim sProcName As Variant
If IsObject(ProcName) = True Then
Set xRange = ProcName
sProcName = GetValues(xRange)
Else
sProcName = ProcName
End If
GetSqlData = sProcName
End Function

Thanks,

Greg


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default How do you get calling cell for custom function

Look up Application.Caller in the help files;there is an example.

"Gregory Cmar" wrote:

I have written a custom function that returns database data to my
spreadsheet. The follwoing code snippet describesthe process. I test the
variable being passed in. If it is an object (cell range like A1:A3), I get
that address and process results based upon the values in those cells.

My question is, how do I get the address of the calling cell (the cell where
I entered the formula)? I want to test whether it is an array formula.

Public Function GetSqlData(ByVal ProcName As Variant) As Variant
Dim sProcName As Variant
If IsObject(ProcName) = True Then
Set xRange = ProcName
sProcName = GetValues(xRange)
Else
sProcName = ProcName
End If
GetSqlData = sProcName
End Function

Thanks,

Greg

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do you get calling cell for custom function

Application.caller

will return the address of the cell with the formula.

Gregory Cmar wrote:

I have written a custom function that returns database data to my
spreadsheet. The follwoing code snippet describesthe process. I test the
variable being passed in. If it is an object (cell range like A1:A3), I get
that address and process results based upon the values in those cells.

My question is, how do I get the address of the calling cell (the cell where
I entered the formula)? I want to test whether it is an array formula.

Public Function GetSqlData(ByVal ProcName As Variant) As Variant
Dim sProcName As Variant
If IsObject(ProcName) = True Then
Set xRange = ProcName
sProcName = GetValues(xRange)
Else
sProcName = ProcName
End If
GetSqlData = sProcName
End Function

Thanks,

Greg


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do you get calling cell for custom function

Typo alert

Application.caller


returns a reference to the cell containing the formula.

Application.Caller.Address

would return the address.

--
Regards,
Tom Ogilvy


"Dave Peterson" wrote in message
...
Application.caller

will return the address of the cell with the formula.

Gregory Cmar wrote:

I have written a custom function that returns database data to my
spreadsheet. The follwoing code snippet describesthe process. I test

the
variable being passed in. If it is an object (cell range like A1:A3), I

get
that address and process results based upon the values in those cells.

My question is, how do I get the address of the calling cell (the cell

where
I entered the formula)? I want to test whether it is an array formula.

Public Function GetSqlData(ByVal ProcName As Variant) As Variant
Dim sProcName As Variant
If IsObject(ProcName) = True Then
Set xRange = ProcName
sProcName = GetValues(xRange)
Else
sProcName = ProcName
End If
GetSqlData = sProcName
End Function

Thanks,

Greg


--

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
Custom Function: Detecting the cell the function is used in g-boy Excel Programming 2 June 11th 05 06:46 PM
Help with #Value error when calling custom functions Carlos Galvez Excel Programming 1 September 9th 04 10:42 PM
VBE Custom menuitem not calling OnAction macro R Avery Excel Programming 4 July 13th 04 10:39 PM
Calling a function in another project from within a cell formula Ellis Horowitz Excel Programming 1 June 25th 04 03:08 PM
Calling a Custom Function within a Procedure [email protected] Excel Programming 1 November 16th 03 03:51 AM


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