R
RLExcelUserTS
Using a VBA macro, I'm looking for the best way to Chart just the "X
axis" and the "Yaxis" from selected columns. Basically, just want to
chart one column vs another column located anywhere in the worksheet.
Tried three ways.
a) Hardcode cell address.
b) Range cell selection.
c) Cell address obtained from range.
I believe there is a better way, but have not found it yet.
Refer to code snipet
*******
Range(XAXISTOPCELLGRAPH1, XAXISTOPCELLGRAPH1).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Range(YAXISTOPCELLGRAPH1, YAXISTOPCELLGRAPH1).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
' Add Chart
Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
' ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
' Range("A1:A602,B1:B602")
' ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
' Range(UXCell, LYCell), PlotBy:=xlColumns
ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
Range(XColRange & "," & YColRange)
ActiveChart.Location Where:=xlLocationAsObject, Name:= _
GRAPHSHEETNAME
*******
Thanks for your help.
axis" and the "Yaxis" from selected columns. Basically, just want to
chart one column vs another column located anywhere in the worksheet.
Tried three ways.
a) Hardcode cell address.
b) Range cell selection.
c) Cell address obtained from range.
I believe there is a better way, but have not found it yet.
Refer to code snipet
*******
Range(XAXISTOPCELLGRAPH1, XAXISTOPCELLGRAPH1).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Range(YAXISTOPCELLGRAPH1, YAXISTOPCELLGRAPH1).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
' Add Chart
Charts.Add
ActiveChart.ChartType = xlXYScatterLinesNoMarkers
' ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
' Range("A1:A602,B1:B602")
' ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
' Range(UXCell, LYCell), PlotBy:=xlColumns
ActiveChart.SetSourceData Source:=Sheets(DATASHEETNAME). _
Range(XColRange & "," & YColRange)
ActiveChart.Location Where:=xlLocationAsObject, Name:= _
GRAPHSHEETNAME
*******
Thanks for your help.