View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
RLExcelUserTS RLExcelUserTS is offline
external usenet poster
 
Posts: 1
Default Using VBA macro - how to just chart two selected columns


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 Whe=xlLocationAsObject, Name:= _

GRAPHSHEETNAME
*******


Thanks for your help.


--
RLExcelUserTS
------------------------------------------------------------------------
RLExcelUserTS's Profile: http://www.excelforum.com/member.php...o&userid=32872
View this thread: http://www.excelforum.com/showthread...hreadid=526778