lucass3231
08-01-2016, 02:25 AM
I have an issue with preparing macro which would select 3 ranges in sheet and then create new sheet with 3 charts from this data. How can I prepare one? Here is what I have at this moment but doesn't work: ActiveChart.Location Where:="Inwestycje wykresy" is highlighted and 'Type missmatch' error occurs. Do I have to also include charts dimensions and position? Here is my code:
Sub InwestycjeWykresy()Range("B3:N5").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B3:N5"), PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Alerty"
End With
Worksheets("Inwestycje").Activate
Range("B6:N7").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B6:N7"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Eskalacje"
End With
Worksheets("Inwestycje").Activate
Range("B8:N10").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B8:N10"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Nadzor"
End With
End Sub
Sub InwestycjeWykresy()Range("B3:N5").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B3:N5"), PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Alerty"
End With
Worksheets("Inwestycje").Activate
Range("B6:N7").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B6:N7"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Eskalacje"
End With
Worksheets("Inwestycje").Activate
Range("B8:N10").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Inwestycje").Range("B8:N10"), PlotBy:=xlRows
ActiveChart.Location Where:="Inwestycje wykresy"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Nadzor"
End With
End Sub