Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RAP RAP is offline
external usenet poster
 
Posts: 49
Default Named range for chart range value?

Hello,
Trying to use VB only to use a combobox to select named range to graph. I
see lots of help, but all (I've seen so far) use formulas in cells. I'm
trying to accomplish the same using VB only.

Example: Dropbox to select which Quarter to report (named ranges = Qtr1,
Qtr2,..)
Qtr1 = sheet2, A1:C1 and so on...
How do I get "Qtr1" into the range value entry box for the range source?..
or can I ?
Thanks,
Randy
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Named range for chart range value?

Hi Randy,

Set the ListFillRange of your ActiveX combobox to a cell range containing
your names. This might be a dynamic named range to expand with your named
Qtr's.

In combobox worksheet module -

Dim chObj As ChartObject
Dim sName As String
On Error Resume Next
sName = ComboBox1.Value
Set chObj = ChartObjects(sName)
On Error GoTo errH

If chObj Is Nothing Then
Set chObj = ChartObjects.Add(10, 10, 300, 150)
With chObj
.Chart.ChartType = xlColumnClustered
.Chart.SetSourceData Source:=Range(sName), _
PlotBy:=xlColumns
.Name = sName
.Chart.HasTitle = True
.Chart.ChartTitle.Characters.Text = sName
.Activate
.Chart.ChartArea.Select
End With
Else
chObj.Activate
chObj.Chart.ChartArea.Select
End If

Exit Sub
errH:
MsgBox "error"
End Sub

You will want to adapt this to your needs such as position & chart type etc.
Try the macro recorder for other chart things.

Regards,
Peter T

"RAP" wrote in message
...
Hello,
Trying to use VB only to use a combobox to select named range to graph. I
see lots of help, but all (I've seen so far) use formulas in cells. I'm
trying to accomplish the same using VB only.

Example: Dropbox to select which Quarter to report (named ranges = Qtr1,
Qtr2,..)
Qtr1 = sheet2, A1:C1 and so on...
How do I get "Qtr1" into the range value entry box for the range source?..
or can I ?
Thanks,
Randy



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Named range for chart range value?

I omitted the procedure name with my copy/paste

Private Sub ComboBox1_Change()
Dim chObj As ChartObject
Dim sName As String
etc

Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Randy,

Set the ListFillRange of your ActiveX combobox to a cell range containing
your names. This might be a dynamic named range to expand with your named
Qtr's.

In combobox worksheet module -

Dim chObj As ChartObject
Dim sName As String
On Error Resume Next
sName = ComboBox1.Value
Set chObj = ChartObjects(sName)
On Error GoTo errH

If chObj Is Nothing Then
Set chObj = ChartObjects.Add(10, 10, 300, 150)
With chObj
.Chart.ChartType = xlColumnClustered
.Chart.SetSourceData Source:=Range(sName), _
PlotBy:=xlColumns
.Name = sName
.Chart.HasTitle = True
.Chart.ChartTitle.Characters.Text = sName
.Activate
.Chart.ChartArea.Select
End With
Else
chObj.Activate
chObj.Chart.ChartArea.Select
End If

Exit Sub
errH:
MsgBox "error"
End Sub

You will want to adapt this to your needs such as position & chart type

etc.
Try the macro recorder for other chart things.

Regards,
Peter T

"RAP" wrote in message
...
Hello,
Trying to use VB only to use a combobox to select named range to graph.

I
see lots of help, but all (I've seen so far) use formulas in cells. I'm
trying to accomplish the same using VB only.

Example: Dropbox to select which Quarter to report (named ranges = Qtr1,
Qtr2,..)
Qtr1 = sheet2, A1:C1 and so on...
How do I get "Qtr1" into the range value entry box for the range

source?..
or can I ?
Thanks,
Randy





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
Chart using named range Tigerxxx Excel Discussion (Misc queries) 1 October 18th 08 11:24 AM
need help using named range in chart Marc Pelletier Charts and Charting in Excel 4 September 29th 08 04:23 PM
Can't chart dynamic named range?? [email protected] Charts and Charting in Excel 4 July 20th 06 08:30 PM
Can I use named range in data range box when creating pie chart? BJackson Charts and Charting in Excel 2 August 17th 05 05:37 PM


All times are GMT +1. The time now is 12:31 PM.

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"