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?
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]