Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Generating a graph using nonadjacent columns

Hello -

I am trying to write a macro that will automatically generate a series of
graphs. I have declared a range variable for each column of data, where the
"A" column is time, my independent variable, and the later columns are
dependent variables.

I am using the ActiveChart.SetSourceData Source:=Range(RangeVariable1,
RangeVariable2) method of defining my data. The problem is when
RangeVariable2 is the data in the "C" column, my graph includes a line for
"B" vs "A" as well as "C" vs "A", and I only want "C" vs "A" plotted. How do
I tell Excel to NOT include the columns between these nonadjacent columns?

(I tried just recording a macro while I did this manually - that code used
the absolute cell references. This doesn't help because I don't know ahead
of time the length of the data).

Any help will be appreciated.

Thanks - John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Generating a graph using nonadjacent columns

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
With Worksheets("Sheet1")
ActiveChart.SetSourceData Source:=Union(.Range(.Range("A1"), .Range("A65536").End(xlUp)), _
.Range(.Range("C1"), .Range("C65536").End(xlUp)))
ActiveChart.Location Whe=xlLocationAsObject, Name:=.Name
End With


--
HTH,
Bernie
MS Excel MVP


"John Easton" wrote in message
...
Hello -

I am trying to write a macro that will automatically generate a series of
graphs. I have declared a range variable for each column of data, where the
"A" column is time, my independent variable, and the later columns are
dependent variables.

I am using the ActiveChart.SetSourceData Source:=Range(RangeVariable1,
RangeVariable2) method of defining my data. The problem is when
RangeVariable2 is the data in the "C" column, my graph includes a line for
"B" vs "A" as well as "C" vs "A", and I only want "C" vs "A" plotted. How do
I tell Excel to NOT include the columns between these nonadjacent columns?

(I tried just recording a macro while I did this manually - that code used
the absolute cell references. This doesn't help because I don't know ahead
of time the length of the data).

Any help will be appreciated.

Thanks - John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Generating a graph using nonadjacent columns

That got it - thanks!

John

"Bernie Deitrick" wrote:

Charts.Add
ActiveChart.ChartType = xlXYScatterLines
With Worksheets("Sheet1")
ActiveChart.SetSourceData Source:=Union(.Range(.Range("A1"), .Range("A65536").End(xlUp)), _
.Range(.Range("C1"), .Range("C65536").End(xlUp)))
ActiveChart.Location Whe=xlLocationAsObject, Name:=.Name
End With


--
HTH,
Bernie
MS Excel MVP


"John Easton" wrote in message
...
Hello -

I am trying to write a macro that will automatically generate a series of
graphs. I have declared a range variable for each column of data, where the
"A" column is time, my independent variable, and the later columns are
dependent variables.

I am using the ActiveChart.SetSourceData Source:=Range(RangeVariable1,
RangeVariable2) method of defining my data. The problem is when
RangeVariable2 is the data in the "C" column, my graph includes a line for
"B" vs "A" as well as "C" vs "A", and I only want "C" vs "A" plotted. How do
I tell Excel to NOT include the columns between these nonadjacent columns?

(I tried just recording a macro while I did this manually - that code used
the absolute cell references. This doesn't help because I don't know ahead
of time the length of the data).

Any help will be appreciated.

Thanks - John




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
Selecting nonadjacent columns? Barnsie Excel Worksheet Functions 1 February 3rd 10 02:28 AM
Nonadjacent columns Barnsie Excel Discussion (Misc queries) 3 February 2nd 10 10:54 PM
Nonadjacent cells FAI_Judge[_2_] Excel Discussion (Misc queries) 4 December 13th 08 09:31 PM
nonadjacent selections schillm228 Excel Worksheet Functions 4 March 22nd 06 12:51 AM
generating an excel graph with C++ george Excel Programming 1 January 4th 05 10:19 PM


All times are GMT +1. The time now is 09:39 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"