Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dynamic chart on multiple worksheets based on named formulas?

Hi, Thank you for any help with following problem:

I want to create dynamic charts, with a similar chart on each
worksheet. The chart values are based on named formulas as range.
This works well as long as I hard code the worksheet name when I use
the named formula as input for the chart values, but not when I want
to use a variable as sheet name.

The example might be clearer:

Sub addstudy_Click()
Dim NewStudyName As String
' ..... (other stuff)

'the program creates a new worksheet and asks the user for a name of
the worksheet, which is assigend to the
' NewStudyName variable

ActiveSheet.Name = NewStudyName
' ...........(other stuff)
'next is the definition of names for the chart source data:
Worksheets(NewStudyName).Names.Add Name:="CDAvalues", RefersToR1C1:= _
"=OFFSET('Worksheets(NewStudyName)'!R40C2,0,1,1,SU M('Worksheets(NewStudyName)'!R38C1))"
'...........(other stuff)
'now I set up the chart:
Dim workchart As Chart
Dim aNewSeries As Series
Set workchart = Charts.Add
ActiveChart.Location Whe=xlLocationAsObject, _
Name:=Worksheets(NewStudyName).Name
With ActiveChart.SeriesCollection(1)
.Name = "CDAs"
.XValues = Worksheets(NewStudyName).Range("c65:cg65")
' alternatively this works too:
.XValues = "=" & "'" & Worksheets(NewStudyName).Name & "'" &
"!R65C3:R65C59"

' and here comes the problem:
'THIS DOESN'T work:
..Values = "=" & "'" & Worksheets(NewStudyName).Name & "'" &
"!CDAvalues"
if I replace the first part of the value assignement by a hard coded
worksheet reference
e.g.:
.Values = "=study1!CDAvalues"
then it works well too.

'rest of the program:
.Name = "=" & "'" & Worksheets(NewStudyName).Name & "'" &
"!R2C2"
End With
' .... (other stuff)

I also tired other versions (and many more that seem less correct):
.Values = Worksheets(NewStudyName).Range("CDAvalues")
.Values = "='Worksheets(NewStudyName)'!CDAvalues"
.Values = "=Worksheets(NewStudyName)!CDAvalues"
.Values = Worksheets(NewStudyName).Names(1).RefersToRange
.Values = Worksheets(NewStudyName).Names("CDAvalues").Refers ToRange
.Values = Names("CDAvalues").RefersToRange

obviously I am lost now.
I want to use worksheet specific names, with workbook names I run into
similar problems (after trying to use formats like:
.Values = "=" & ThisWorkbook.Name & "!CDAvalues" ).

If you could help me I very much appreciate it. I work with EXCEL
2000.

Thank you, Andreas
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
Dynamic Named Range for a Chart PFLY Excel Discussion (Misc queries) 1 February 11th 10 07:36 PM
MS Query Refresh Based on Dynamic Named Range bwilk77 Excel Discussion (Misc queries) 0 May 26th 09 02:17 PM
Named Ranges and Dynamic Formulas Josh O. Excel Worksheet Functions 4 April 1st 09 07:40 PM
Can't chart dynamic named range?? [email protected] Charts and Charting in Excel 4 July 20th 06 08:30 PM
Named dynamic ranges, copied worksheets and graph source data WP Charts and Charting in Excel 1 November 28th 04 05:19 PM


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