Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
change color to selected columns in a stacked column chart Noa Charts and Charting in Excel 2 April 28th 23 07:45 PM
Copying selected columns from 1 chart to another. Darren Charts and Charting in Excel 1 February 2nd 10 10:00 PM
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
A recorded Macro to hide certain selected columns hides non selec. Mlmotter Excel Programming 2 December 31st 04 02:56 PM
check for selected columns in a macro philip watson Excel Programming 1 December 2nd 03 09:48 PM


All times are GMT +1. The time now is 09:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"