Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to retrieve range in formula?

I need to create a chart of values that are contained in a cell's formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a chart
based on the range H1:H10. I will not know what range is specified in the
cell's formula until the cell is selected. Is there any way to retrieve the
range that's contained in the cells formula?

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to retrieve range in formula?

You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in message
om...
I need to create a chart of values that are contained in a cell's formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a chart
based on the range H1:H10. I will not know what range is specified in the
cell's formula until the cell is selected. Is there any way to retrieve

the
range that's contained in the cells formula?

Thanks in advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to retrieve range in formula?


"Tom Ogilvy" wrote in message
...
You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in message
om...
I need to create a chart of values that are contained in a cell's

formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a chart
based on the range H1:H10. I will not know what range is specified in

the
cell's formula until the cell is selected. Is there any way to retrieve

the
range that's contained in the cells formula?

Thanks in advance.






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to retrieve range in formula?

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10


Thanks for the quick reply. I'll give it a shot and post back.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to retrieve range in formula?

great.
as I understand direct precedents is the formula
what is meant by directdependents
thanks and regards

Tom Ogilvy wrote in message
...
You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in message
om...
I need to create a chart of values that are contained in a cell's

formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a chart
based on the range H1:H10. I will not know what range is specified in

the
cell's formula until the cell is selected. Is there any way to retrieve

the
range that's contained in the cells formula?

Thanks in advance.










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to retrieve range in formula?

You can use the directprecedents property

I put this code in a module and call it from a button on Sheet1 - seems to
be working okay...

Public Sub CreateChart(bytChart As Byte)
Dim sChart As Chart
Dim sRange As Range
Set sRange = Application.ActiveWindow.ActiveCell.DirectPreceden ts
Sheet2.ChartObjects(1).Delete
Set sChart = Charts.Add
With sChart
.chartType = xlBarClustered
.SetSourceData Source:=sRange, PlotBy:=xlRows
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue
.Location xlLocationAsObject, "Sheet2"
End With
With Sheet2.ChartObjects(1)
.Width = 600
.Height = 400
.Top = 20
.Left = 100
End With
End Sub

Thanks for the help!


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to retrieve range in formula?

If your asking what is directprecedents, it is any ranges that the formula
in the cell depends on.

However, It doesn't work for linked to cells - cells on other worksheets, on
cells/ranges on the same sheet.

--
Regards,
Tom Ogilvy

"R.VENKATARAMAN" $$$ wrote in message
...
great.
as I understand direct precedents is the formula
what is meant by directdependents
thanks and regards

Tom Ogilvy wrote in message
...
You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in message
om...
I need to create a chart of values that are contained in a cell's

formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a

chart
based on the range H1:H10. I will not know what range is specified in

the
cell's formula until the cell is selected. Is there any way to

retrieve
the
range that's contained in the cells formula?

Thanks in advance.










  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to retrieve range in formula?

However, It doesn't work for linked to cells - cells on other worksheets,
on
cells/ranges on the same sheet.


Yes, I discovered this limitation - which conflicts with the requirements I
was given. I don't see why the Excel team couldn't make this work.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default How to retrieve range in formula?

thanks Mr. Ogilvy.
I have understood the term <directprecedents. But when i went to help(vba)
of this term I find another term <directdependents in <see also of this
help.
I would like to know the utility of this function. regards

mine excel 2000
===============
Tom Ogilvy wrote in message
...
If your asking what is directprecedents, it is any ranges that the formula
in the cell depends on.

However, It doesn't work for linked to cells - cells on other worksheets,

on
cells/ranges on the same sheet.

--
Regards,
Tom Ogilvy

"R.VENKATARAMAN" $$$ wrote in message
...
great.
as I understand direct precedents is the formula
what is meant by directdependents
thanks and regards

Tom Ogilvy wrote in message
...
You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in

message
om...
I need to create a chart of values that are contained in a cell's

formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a

chart
based on the range H1:H10. I will not know what range is specified

in
the
cell's formula until the cell is selected. Is there any way to

retrieve
the
range that's contained in the cells formula?

Thanks in advance.














  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to retrieve range in formula?

I would surmise the problem is somehow concerned with the fact that it
returns a single range object. This would work if all the precedents were
on a single sheet - either the same sheet as the formula or on the same
external sheet. However, if the arguments involved a mix of sheets, then a
single range object can not address multiple sheets. Perhaps the function
should return an array.

--
Regards,
Tom Ogilvy

"deko" wrote in message
m...
However, It doesn't work for linked to cells - cells on other

worksheets,
on
cells/ranges on the same sheet.


Yes, I discovered this limitation - which conflicts with the requirements

I
was given. I don't see why the Excel team couldn't make this work.






  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to retrieve range in formula?

DirectDependents are those cells for which the cell in question is a
DirectPrecedent

if A1 had the formula
=C1

Range("A1").DirectPrecedents
would return a range reference to C1

Range("C1").DirectDependents
would return a range reerence to A1

as shown from the immediate window:


? Range("A1").Formula
=C1
? Range("A1").DirectPrecedents.Address
$C$1
? Range("C1").DirectDependents.Address
$A$1

--
Regards,
Tom Ogilvy


"R.VENKATARAMAN" $$$ wrote in message
...
thanks Mr. Ogilvy.
I have understood the term <directprecedents. But when i went to

help(vba)
of this term I find another term <directdependents in <see also of this
help.
I would like to know the utility of this function. regards

mine excel 2000
===============
Tom Ogilvy wrote in message
...
If your asking what is directprecedents, it is any ranges that the

formula
in the cell depends on.

However, It doesn't work for linked to cells - cells on other

worksheets,
on
cells/ranges on the same sheet.

--
Regards,
Tom Ogilvy

"R.VENKATARAMAN" $$$ wrote in message
...
great.
as I understand direct precedents is the formula
what is meant by directdependents
thanks and regards

Tom Ogilvy wrote in message
...
You can use the directprecedents property

demo'd from the immeditate window.

? ActiveCell.Formula
=STDEV(Sheet1!H1:H10)

set rng = ActiveCell.DirectPrecedents

? rng.Address
$H$1:$H$10

? rng.Address(0,0,,True)
[Book1]Sheet1!H1:H10

--
Regards,
Tom Ogilvy


"deko" wrote in

message
om...
I need to create a chart of values that are contained in a cell's
formula.
For example, if cell A1 has this formula:

=STDEV(Sheet1!H1:H10)

I want to be able select that cell, click a button, and produce a

chart
based on the range H1:H10. I will not know what range is

specified
in
the
cell's formula until the cell is selected. Is there any way to

retrieve
the
range that's contained in the cells formula?

Thanks in advance.
















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
Retrieve last non zero value in a range of cells Pete[_5_] New Users to Excel 2 June 10th 11 08:57 PM
How to retrieve Named Range name? Guntars Excel Worksheet Functions 3 June 8th 09 03:06 AM
Need formula to retrieve last non-blank cell in range Eric Excel Discussion (Misc queries) 7 July 20th 06 01:29 PM
Retrieve value from a range of cells EMoe Excel Worksheet Functions 3 June 19th 06 07:02 PM
Formula to retrieve range of dates from a worksheet to calculate d accented Excel Worksheet Functions 0 January 10th 06 09:52 PM


All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"