Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looking for help with macros and chart making.

My spreadsheet: Rows A thru BU, Columns 1 thru 34. Keeps tracks of stats.
What I'm trying to do: I want the user to be able to click a button (or a
hotkey) to create a chart that will show a columns data so that they can
visualy see the evolution of a particular stat.

Where I currently stand: I can accomplish this with a macro but only for one
column. Here's my code...

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 1/26/2005 by
'
'
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("December 2004").Range( _
"B4:B34,J4:J34"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="December 2004"
ActiveChart.HasLegend = False

End Sub

Is there a way to change 'ActiveChart.SetSourceData Source:=Sheets("December
2004").Range("B4:B34,J4:J34"), PlotBy:=xlColumns' so that instead of a static
range it uses where ever cell the user has selected to generate the chart?
What I want exactly is for the user to be able to point at say B4 and then
start a macro which will create a chart like i made above using a range of
B4:B34. But, if the user selects C4 I want a chart to be made with a range of
C4:C34. I am very much a beginner at coding in Excel and not sure how to
accomplish this.

Any help would be much appriciated!
-mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Looking for help with macros and chart making.

' Macro3 Macro
' Macro recorded 1/26/2005 by
'
'
Dim sStr as String
sStr = cells(4,ActiveCell.Column).Resize(31,1).Address(0, 0) & _
",J4:J34"
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("December 2004").Range( _
sStr), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="December 2004"
ActiveChart.HasLegend = False

End Sub

--
Regards,
Tom Ogilvy


"mike drav" wrote in message
...
My spreadsheet: Rows A thru BU, Columns 1 thru 34. Keeps tracks of stats.
What I'm trying to do: I want the user to be able to click a button (or a
hotkey) to create a chart that will show a columns data so that they can
visualy see the evolution of a particular stat.

Where I currently stand: I can accomplish this with a macro but only for

one
column. Here's my code...

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 1/26/2005 by
'
'
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("December 2004").Range( _
"B4:B34,J4:J34"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="December 2004"
ActiveChart.HasLegend = False

End Sub

Is there a way to change 'ActiveChart.SetSourceData

Source:=Sheets("December
2004").Range("B4:B34,J4:J34"), PlotBy:=xlColumns' so that instead of a

static
range it uses where ever cell the user has selected to generate the chart?
What I want exactly is for the user to be able to point at say B4 and then
start a macro which will create a chart like i made above using a range of
B4:B34. But, if the user selects C4 I want a chart to be made with a range

of
C4:C34. I am very much a beginner at coding in Excel and not sure how to
accomplish this.

Any help would be much appriciated!
-mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Looking for help with macros and chart making.

One easier way to do this would be to set up a defined name range such as
mycol=offset($a$4,0,column()-1,counta($A:$A),1) and then a double click
event to force calculation.
Then your series is set to =yourworkbookname.xls!mycol
Now when you double click the column it will chart that column to the
longest row in col A.

--
Don Guillett
SalesAid Software

"mike drav" wrote in message
...
My spreadsheet: Rows A thru BU, Columns 1 thru 34. Keeps tracks of stats.
What I'm trying to do: I want the user to be able to click a button (or a
hotkey) to create a chart that will show a columns data so that they can
visualy see the evolution of a particular stat.

Where I currently stand: I can accomplish this with a macro but only for

one
column. Here's my code...

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 1/26/2005 by
'
'
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("December 2004").Range( _
"B4:B34,J4:J34"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="December 2004"
ActiveChart.HasLegend = False

End Sub

Is there a way to change 'ActiveChart.SetSourceData

Source:=Sheets("December
2004").Range("B4:B34,J4:J34"), PlotBy:=xlColumns' so that instead of a

static
range it uses where ever cell the user has selected to generate the chart?
What I want exactly is for the user to be able to point at say B4 and then
start a macro which will create a chart like i made above using a range of
B4:B34. But, if the user selects C4 I want a chart to be made with a range

of
C4:C34. I am very much a beginner at coding in Excel and not sure how to
accomplish this.

Any help would be much appriciated!
-mike



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
Making macros unvisible Byron720 Excel Discussion (Misc queries) 5 January 15th 10 06:53 PM
Making macros available to other excel files Fred Zack Excel Discussion (Misc queries) 2 June 10th 08 03:28 PM
Making Macros Available in All Workbooks QUESTION-MARK Excel Worksheet Functions 2 May 23rd 06 01:47 PM
Making a copy using macros legepe[_10_] Excel Programming 0 October 23rd 04 02:20 AM
Making excel macros run Word macros Matthew McManus Excel Programming 1 February 18th 04 02:57 AM


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