Trouble automating creation of charts/graphs

vbanewb14

New Member
Joined
Apr 7, 2010
Messages
1
Hi,

I'm a newb at VBA and am having a little trouble finding help on what I'm trying to code. Would appreciate any help anyone can provide.

Basically, I am writing a macro to automate the process of creating multiple graphs. I plan to write some code (later)which will output a list of row numbers. I need this code to be able to loop through that list and create a graph for each of those rows.

I tried to define variables for the data range so that I can loop through and just change the variable, but I don't think I am doing it correctly. Any advice?

Code:
[LIST=1]<LI class=codeLI>Sub LoudnessChart() <LI class=codeLI>Dim LChart As ChartObject <LI class=codeLI>Dim Lrange As Range <LI class=codeLI>Dim Lrow As String <LI class=codeLI>Dim Lstr As String <LI class=codeLI>Dim Lname As String <LI class=codeLI>  <LI class=codeLI>Lrow = 170 <LI class=codeLI>Lstr = "Range(" & Chr(34) & "Summary!G" & Lrow & ":V" & Lrow & Chr(34) & ").Values" <LI class=codeLI>Set Lrange = Lstr <LI class=codeLI>  <LI class=codeLI>  <LI class=codeLI> Windows("Sorted.xls").Activate <LI class=codeLI>    Sheets("Temp").Select <LI class=codeLI>    Set LChart = ActiveSheet.ChartObjects.Add _ <LI class=codeLI>        (Left:=100, Width:=375, Top:=75, Height:=225) <LI class=codeLI> ' <LI class=codeLI>   LChart.Chart.SetSourceData Source:=Lrange <LI class=codeLI>    LChart.Chart.ChartType = xlColumnClustered <LI class=codeLI>    LChart.Chart.SeriesCollection(1).XValues = "=Summary!R3C7:R4C22" <LI class=codeLI>  <LI class=codeLI>Lname = Chr(34) & "=Summary!R" & Lrow & "C3" & Chr(34) <LI class=codeLI>  <LI class=codeLI>    LChart.Chart.SeriesCollection(1).Name = Lname <LI class=codeLI>       With Schart.Chart <LI class=codeLI>        .HasTitle = True <LI class=codeLI>        .ChartTitle.Characters.Text = "Power Door Lock Power  Lock Peak Sharpness" <LI class=codeLI>        .Axes(xlCategory).HasTitle = False <LI class=codeLI>        .Axes(xlCategory).TickLabelSpacing = 1 <LI class=codeLI>        .Axes(xlCategory).TickLabels.Orientation = xlUpward <LI class=codeLI>        .Axes(xlValue).HasTitle = True <LI class=codeLI>        .Axes(xlValue).AxisTitle.Characters.Text = "Acum" <LI class=codeLI>        .HasLegend = False <LI class=codeLI>    End With 
[*]End Sub
[/LIST]
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,216,158
Messages
6,129,207
Members
449,493
Latest member
JablesFTW

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top