Excel Macro to automatically change chart line style based on cell text

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

remboi

Thread Starter
Joined
Nov 6, 2007
Messages
25
Hi,

My VBA/Macro knowledge is very basic, but I am able to record macros and edit them. I have a scatter plot (with 5 series) and I want to automatically change the line style (i.e. solid or dashed etc.) depending on the text in a cell. This is what I tried, but I cannot get the code to reference the cell which contains the text:

--------------------------------------------------------------

Sub Macro14()
'
' Macro14 Macro
'
'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineSolid
End With
End Sub


--------------------------------------------------------------

For the line ".DashStyle = msoLineSolid" I tried ".DashStyle = Range("A7").Select" but this does not work.

Is there a simpler way to set-up a macro to format graphs automatically based on a cell content/format/colour, does anyone know a good guide to do this?

Thanks
 

remboi

Thread Starter
Joined
Nov 6, 2007
Messages
25
Thanks for the reply, that's what I want to be able to do, but instead of having the code for the cap type etc. in the code I want to put this as text in a cell, so when i change the text in the cell and run the macro it will change it on the chart.

e.g. in cell A1 I would enter msoLineLongDashDot (or some other format attribute) and in the code reference this with a command like sr.Border.LineStyle = A1

i.e. can you take the text from a cell and use it in a command line?
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top