G
Guest
I am working a a macro that creates a chart and then names itself. The name
could change depending on which stat the code is being ran from. I have it
working as a single macro but I do not want to repeat all of the code so I
can save on size. I have a button on my output page that selects a range of
data on my Raw Data sheet, then it starts running the macro to create the
graph. I want to get the graph code to name the sheet "Manager_AHT_Graph" or
Manager_IR_Graph" or any of the other stats that I am trending data for.
Here is where I am with the code that works fine.
Sub Create_AHT_Graph()
Range(Selection, Selection.End(xlDown)).Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"Manager_AHT_Graph"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Now what I want it to do is take the AHT part of the name and use
cell.offset to move to the "header" row (not actually a header since it is at
line 252) and use that name. If I am picturing it right in my head, when I
push the button to run the IR graph then it should select the range and begin
creating the chart then when it goes to name it the code should be something
like (because this pukes on itself) this:
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"Manager_" & cell.Offset(1, 0) & "_Graph"
Any ideas how I can get this to work? Or a better way of not repeating that
code for every button that I need to create a graph?
Thank you,
could change depending on which stat the code is being ran from. I have it
working as a single macro but I do not want to repeat all of the code so I
can save on size. I have a button on my output page that selects a range of
data on my Raw Data sheet, then it starts running the macro to create the
graph. I want to get the graph code to name the sheet "Manager_AHT_Graph" or
Manager_IR_Graph" or any of the other stats that I am trending data for.
Here is where I am with the code that works fine.
Sub Create_AHT_Graph()
Range(Selection, Selection.End(xlDown)).Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"Manager_AHT_Graph"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Now what I want it to do is take the AHT part of the name and use
cell.offset to move to the "header" row (not actually a header since it is at
line 252) and use that name. If I am picturing it right in my head, when I
push the button to run the IR graph then it should select the range and begin
creating the chart then when it goes to name it the code should be something
like (because this pukes on itself) this:
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"Manager_" & cell.Offset(1, 0) & "_Graph"
Any ideas how I can get this to work? Or a better way of not repeating that
code for every button that I need to create a graph?
Thank you,