Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Where was I called from?

What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Where was I called from?

Try Worksheet.name in the Immediate Window

Prof Wonmug wrote:

What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Where was I called from?

Are these what you are looking for...ActiveWorkBook.Name, ActiveSheet.Name,
ActiveCell.Address?

--
Rick (MVP - Excel)


"Prof Wonmug" wrote in message
...
What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Where was I called from?

Here is something out of the VBA help files.

This example displays information about how Visual Basic was called.

Select Case TypeName(Application.Caller)
Case "Range"
v = Application.Caller.Address
Case "String"
v = Application.Caller
Case "Error"
v = "Error"
Case Else
v = "unknown"
End Select
MsgBox "caller = " & v


"Prof Wonmug" wrote in message
...
What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Where was I called from?

Look at Application.Caller (.Address)
Remember that the active sheet/book doesn't have to be the one that a UDF
was called from
It all depends on what you're trying to achieve. Maybe you should post that.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Prof Wonmug" wrote in message
...
What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Where was I called from?

On Sat, 9 May 2009 15:48:44 -0400, "Rick Rothstein"
wrote:

Are these what you are looking for...ActiveWorkBook.Name, ActiveSheet.Name,
ActiveCell.Address?


Yup. Thanks.

In these examples, is the first field called an "object" and the
second a "property"?

Is there a nice concise list of the first field, with sublists for the
second (and third?)?
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Where was I called from?

On Sat, 9 May 2009 16:01:36 -0400, "JLGWhiz"
wrote:

Here is something out of the VBA help files.

This example displays information about how Visual Basic was called.

Select Case TypeName(Application.Caller)
Case "Range"
v = Application.Caller.Address
Case "String"
v = Application.Caller
Case "Error"
v = "Error"
Case Else
v = "unknown"
End Select
MsgBox "caller = " & v


"Prof Wonmug" wrote in message
.. .
What property do I need to qeury to obtain the name of the workbook,
sheet, and cell where a UDF or macro was called?


Thanks. I'll have to study that one.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 61
Default Where was I called from?

On Sat, 9 May 2009 22:29:15 +0200, "Niek Otten"
wrote:

Look at Application.Caller (.Address)


Both of those get an error in the immediate window when the UDF is
running.

Remember that the active sheet/book doesn't have to be the one that a UDF
was called from
It all depends on what you're trying to achieve. Maybe you should post that.


I'm just trying to determine which cell in which sheet called the UDF.
Rick's solution gave me what I needed.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Where was I called from?

In these cases, yes; however, if the second ones ever performed an action as
opposed to simply returning a value, then they would be called methods.

--
Rick (MVP - Excel)


"Prof Wonmug" wrote in message
...
On Sat, 9 May 2009 15:48:44 -0400, "Rick Rothstein"
wrote:

Are these what you are looking for...ActiveWorkBook.Name,
ActiveSheet.Name,
ActiveCell.Address?


Yup. Thanks.

In these examples, is the first field called an "object" and the
second a "property"?

Is there a nice concise list of the first field, with sublists for the
second (and third?)?


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Where was I called from?

Rick's solution only works if the UDF is called from whatever sheet happens
to be the active sheet:
If you call the UDF from 2 separate worksheets it is bound to give the wrong
answer.

As Niek was pointing out inside a UDF you need:

Application.Caller.Address for the address of the cell that called the UDF
Application.Caller.Parent.Name for the name of the worksheet containing the
cell that called the UDF

(Application.Caller returns a Range object referring to the cell that called
the UDF)

regards
Charles
___________________________________
The Excel Calculation Site
http://www.decisionmodels.com

"Prof Wonmug" wrote in message
...
On Sat, 9 May 2009 22:29:15 +0200, "Niek Otten"
wrote:

Look at Application.Caller (.Address)


Both of those get an error in the immediate window when the UDF is
running.

Remember that the active sheet/book doesn't have to be the one that a UDF
was called from
It all depends on what you're trying to achieve. Maybe you should post
that.


I'm just trying to determine which cell in which sheet called the UDF.
Rick's solution gave me what I needed.



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
Tell whether or not Sub B was called by Sub A? IanKR Excel Programming 6 March 4th 09 06:19 PM
May I called a Programmer if... Shazi Excel Programming 4 August 17th 08 05:55 PM
called macro Rick Excel Programming 4 December 19th 07 11:31 PM
what is this called? : < Jake Excel Worksheet Functions 1 November 28th 06 11:01 AM
Run Workbook_Open only if called Jarek[_13_] Excel Programming 1 September 17th 04 03:10 PM


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