Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 7
Default How to write a macro to modify an Excel chart

I want to "record" a macro that, for example, changes the line styles on an
Excel chart. I tried by selecting the chart, then clicking on "record
macro", manually changing the line style, and then clicking on "stop
recording". But then when I tried to use the macro it wouldn't do anything.
When I edited the macro there was no code, just the comment lines giving the
shortcut.

Is it possible to use the "record" feature for macros that work with charts,
or must one start with the VB editor?
Thanks,
Henry
--
leave well enough alone
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,344
Default How to write a macro to modify an Excel chart

Hi,

Here is the macro I get when starting in the spreadsheet:

Sub FormatChartLine()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlDash
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlAutomatic
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

Starting on the chart produces something like this:

Sub Macro2()
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

What version of Excel are you using?

--
Cheers,
Shane Devenshire


"raymondvillain" wrote:

I want to "record" a macro that, for example, changes the line styles on an
Excel chart. I tried by selecting the chart, then clicking on "record
macro", manually changing the line style, and then clicking on "stop
recording". But then when I tried to use the macro it wouldn't do anything.
When I edited the macro there was no code, just the comment lines giving the
shortcut.

Is it possible to use the "record" feature for macros that work with charts,
or must one start with the VB editor?
Thanks,
Henry
--
leave well enough alone

  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 7
Default How to write a macro to modify an Excel chart

Oops! Forgot to say Excel 2007. Thanks for your suggestion.
Henry
--
leave well enough alone


"ShaneDevenshire" wrote:

Hi,

Here is the macro I get when starting in the spreadsheet:

Sub FormatChartLine()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlDash
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlAutomatic
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

Starting on the chart produces something like this:

Sub Macro2()
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

What version of Excel are you using?

--
Cheers,
Shane Devenshire


"raymondvillain" wrote:

I want to "record" a macro that, for example, changes the line styles on an
Excel chart. I tried by selecting the chart, then clicking on "record
macro", manually changing the line style, and then clicking on "stop
recording". But then when I tried to use the macro it wouldn't do anything.
When I edited the macro there was no code, just the comment lines giving the
shortcut.

Is it possible to use the "record" feature for macros that work with charts,
or must one start with the VB editor?
Thanks,
Henry
--
leave well enough alone

  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default How to write a macro to modify an Excel chart

Unfortunately, the Excel 2007 macro recorder doesn't record too much when
you are editing charts (and nothing at all when you are editing shapes). I
think they were out of time when 2007 was being released, and couldn't
upgrade it for the new Office shapes.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"raymondvillain" wrote in message
...
Oops! Forgot to say Excel 2007. Thanks for your suggestion.
Henry
--
leave well enough alone


"ShaneDevenshire" wrote:

Hi,

Here is the macro I get when starting in the spreadsheet:

Sub FormatChartLine()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlDash
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlAutomatic
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

Starting on the chart produces something like this:

Sub Macro2()
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

What version of Excel are you using?

--
Cheers,
Shane Devenshire


"raymondvillain" wrote:

I want to "record" a macro that, for example, changes the line styles
on an
Excel chart. I tried by selecting the chart, then clicking on "record
macro", manually changing the line style, and then clicking on "stop
recording". But then when I tried to use the macro it wouldn't do
anything.
When I edited the macro there was no code, just the comment lines
giving the
shortcut.

Is it possible to use the "record" feature for macros that work with
charts,
or must one start with the VB editor?
Thanks,
Henry
--
leave well enough alone



  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,344
Default How to write a macro to modify an Excel chart

Hi,

In that case its going to be more work because you will need to write the
macro manually.

--
Cheers,
Shane Devenshire


"raymondvillain" wrote:

Oops! Forgot to say Excel 2007. Thanks for your suggestion.
Henry
--
leave well enough alone


"ShaneDevenshire" wrote:

Hi,

Here is the macro I get when starting in the spreadsheet:

Sub FormatChartLine()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlDash
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlAutomatic
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

Starting on the chart produces something like this:

Sub Macro2()
With Selection.Border
.ColorIndex = 57
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlAutomatic
.MarkerForegroundColorIndex = xlAutomatic
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
End Sub

What version of Excel are you using?

--
Cheers,
Shane Devenshire


"raymondvillain" wrote:

I want to "record" a macro that, for example, changes the line styles on an
Excel chart. I tried by selecting the chart, then clicking on "record
macro", manually changing the line style, and then clicking on "stop
recording". But then when I tried to use the macro it wouldn't do anything.
When I edited the macro there was no code, just the comment lines giving the
shortcut.

Is it possible to use the "record" feature for macros that work with charts,
or must one start with the VB editor?
Thanks,
Henry
--
leave well enough alone



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
Saving a copy of excel file in macro but have it auto write pano Excel Worksheet Functions 4 March 27th 07 11:54 PM
Modify Macro Code Depending on Excel Version John Taylor Excel Discussion (Misc queries) 11 February 26th 07 04:19 AM
How do I write an auto macro to undo filtering at statup in Excel Jackie Excel Worksheet Functions 0 May 23rd 06 05:49 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
How to write a macro to get the system time in excel 97 Raj Excel Discussion (Misc queries) 6 April 20th 05 07:20 PM


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