Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Application.caller

Hi!

I have a very tricky problem. It is rather complicated so I provide a short
description and a detailed description of my problem.

Short version:
In a User defined function I can use Application.Caller.Address to find out
which cell is calling the function.
How can I get info on which sheet and in which workbook this cell is at
runtime?
Is there not properties like
Application.Caller.Sheet.Name
and
Application.Caller.Workbook.Name ??


Long version
I retrieve data into excel using user defined formulas in an add-in. A .NET
dll connects to the SQL Server db and returns the requested data. So in a
cell I enter
=GetData("2003";"Q1";"Profit")

Now I do not want the program to fetch data directly, so in the VBA function
GetData there is no actual code for connecting to database. The retrieval is
done by another macro, triggered by a button click from user. The data
retrieved is stored in a array, and then distributed to cells containing the
GetData formula.

In short this is the process:
1. User enters the GetData formula in a cell
2. The user defined function in VBE is triggered and returns string "Value
not updated"
3. User clicks update button in customized toolbar
4. a Update macro finds all cells with GetData formula,
b stores the arguments in an array and also a reference to the calling
cell using Application.Caller.Address
c sends array to .NET component
d analyzes arguments
e create SQL
f gets data
g returns data back to Excel as an array
5. Update macro uses Application.CalculateFull
6. This triggers GetData formula, which use the data in the returned array
to populate cells.

This works splendid with only one worksheet, but with several worksheets and
workbooks I do no know on which worksheet or in which workbook the calling
calling cell is in, so I can't choose the correct data from the array. The
solutions is to include also worksheet name and workbook name in the array
building (step 4b). I need properties like
Application.Caller.Sheet.Name and
Application.Caller.Workbook.Name
but have not found anything like this.


Best Regards

Clark B


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Application.caller

Clark,

This might do what your looking for!

Application.Caller.Activate
MyBook = ActiveWorkbook.Name
MySheet = ActiveSheet.Name

Dan E

"Clark B" wrote in message
...
Hi!

I have a very tricky problem. It is rather complicated so I provide a

short
description and a detailed description of my problem.

Short version:
In a User defined function I can use Application.Caller.Address to find

out
which cell is calling the function.
How can I get info on which sheet and in which workbook this cell is at
runtime?
Is there not properties like
Application.Caller.Sheet.Name
and
Application.Caller.Workbook.Name ??


Long version
I retrieve data into excel using user defined formulas in an add-in. A

..NET
dll connects to the SQL Server db and returns the requested data. So in a
cell I enter
=GetData("2003";"Q1";"Profit")

Now I do not want the program to fetch data directly, so in the VBA

function
GetData there is no actual code for connecting to database. The retrieval

is
done by another macro, triggered by a button click from user. The data
retrieved is stored in a array, and then distributed to cells containing

the
GetData formula.

In short this is the process:
1. User enters the GetData formula in a cell
2. The user defined function in VBE is triggered and returns string "Value
not updated"
3. User clicks update button in customized toolbar
4. a Update macro finds all cells with GetData formula,
b stores the arguments in an array and also a reference to the calling
cell using Application.Caller.Address
c sends array to .NET component
d analyzes arguments
e create SQL
f gets data
g returns data back to Excel as an array
5. Update macro uses Application.CalculateFull
6. This triggers GetData formula, which use the data in the returned array
to populate cells.

This works splendid with only one worksheet, but with several worksheets

and
workbooks I do no know on which worksheet or in which workbook the calling
calling cell is in, so I can't choose the correct data from the array. The
solutions is to include also worksheet name and workbook name in the array
building (step 4b). I need properties like
Application.Caller.Sheet.Name and
Application.Caller.Workbook.Name
but have not found anything like this.


Best Regards

Clark B




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Application.caller

Splendid!

It works like a charm!

Thanks!

"Charles Williams" wrote in message
...
Hi Clark B,

assuming you are using application.caller inside the UDF then

sheet name is
Application.caller.parent.name
book name is
application.caller.parent.parent.name

hth
Charles
______________________
Decision Models
The Excel Calculation Site
www.DecisionModels.com

"Clark B" wrote in message
...
Hi!

I have a very tricky problem. It is rather complicated so I provide a

short
description and a detailed description of my problem.

Short version:
In a User defined function I can use Application.Caller.Address to find

out
which cell is calling the function.
How can I get info on which sheet and in which workbook this cell is at
runtime?
Is there not properties like
Application.Caller.Sheet.Name
and
Application.Caller.Workbook.Name ??


Long version
I retrieve data into excel using user defined formulas in an add-in. A

.NET
dll connects to the SQL Server db and returns the requested data. So in

a
cell I enter
=GetData("2003";"Q1";"Profit")

Now I do not want the program to fetch data directly, so in the VBA

function
GetData there is no actual code for connecting to database. The

retrieval
is
done by another macro, triggered by a button click from user. The data
retrieved is stored in a array, and then distributed to cells containing

the
GetData formula.

In short this is the process:
1. User enters the GetData formula in a cell
2. The user defined function in VBE is triggered and returns string

"Value
not updated"
3. User clicks update button in customized toolbar
4. a Update macro finds all cells with GetData formula,
b stores the arguments in an array and also a reference to the

calling
cell using Application.Caller.Address
c sends array to .NET component
d analyzes arguments
e create SQL
f gets data
g returns data back to Excel as an array
5. Update macro uses Application.CalculateFull
6. This triggers GetData formula, which use the data in the returned

array
to populate cells.

This works splendid with only one worksheet, but with several worksheets

and
workbooks I do no know on which worksheet or in which workbook the

calling
calling cell is in, so I can't choose the correct data from the array.

The
solutions is to include also worksheet name and workbook name in the

array
building (step 4b). I need properties like
Application.Caller.Sheet.Name and
Application.Caller.Workbook.Name
but have not found anything like this.


Best Regards

Clark B







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
Application.Caller with Command Buttons? RBee Excel Discussion (Misc queries) 3 August 15th 06 06:39 PM
Application.Caller Marcelo Excel Discussion (Misc queries) 6 June 23rd 06 03:07 PM
range moves with application caller ME @ Home Excel Discussion (Misc queries) 1 February 20th 06 02:22 PM
Row = Application.Caller.Row Charles Woll Excel Worksheet Functions 8 February 28th 05 02:04 PM
DDE and application.caller help Ross Kaminsky Excel Programming 1 July 17th 03 04:17 PM


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