Looking for help with macros and chart making.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: mike drav (mikedrav_at_discussions.microsoft.com)
Date: 01/26/05


Date: Wed, 26 Jan 2005 08:37:19 -0800

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 Where:=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



Relevant Pages

  • Re: Looking for help with macros and chart making.
    ... Now when you double click the column it will chart that column to the ... > Sub Macro3() ... > ' Macro3 Macro ... > accomplish this. ...
    (microsoft.public.excel.programming)
  • Re: Update "buildin" excel in a powerpoint with macro
    ... Problem #2 - How to get the macro to run more than a single time. ... make a simple chart in an Excel workbook ... Switch to a new empty PowerPoint presentation ... Switch back to Excel and quit Excel ...
    (microsoft.public.mac.office.powerpoint)
  • Re: Copying Charts While Changing Source Data
    ... The macro isn't on the web site (I may post it, though, because it's a good ... Const nRowsTall As Long = 12 ... ' chart layout ... Dim chtob As ChartObject ...
    (microsoft.public.excel.charting)
  • Re: Copying Charts While Changing Source Data
    ... Here's a macro that will create an array of charts, ... Const nRowsTall As Long = 12 ... Dim chtob As ChartObject ... I created a macro so that I could get to the code. ...
    (microsoft.public.excel.charting)
  • Re: Copying Charts While Changing Source Data
    ... The macro that you created will be ... The initial chart would pull data from ... Jon Peltier, Microsoft Excel MVP ... Dim chtob As ChartObject ...
    (microsoft.public.excel.charting)