XY chart

R

Rob

I have 2 columns of data A1 B1 10 rows down

I want to create a line chart using column A as the Y axis and column B as
the X axis
have been told this is not possible, is that right?

Thanks Rob.
 
J

Jon Peltier

Rob -

You do this a lot, build your chart the wrong way? Here's a macro that
lets you select your data (Y in the first column, X in the second) and
build a line chart.

Sub AddChartYX()
'' Select 2-column range for chart
'' First column has Y data, second column has X data
'' First row contains labels/headers
Dim oChtObj As ChartObject
Dim rngData As Range
Set rngData = Selection

Set oChtObj = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=375, Top:=75, Height:=225)
oChtObj.Chart.ChartType = xlLineMarkers
With oChtObj.Chart.SeriesCollection.NewSeries
.Name = rngData.Cells(1, 1)
.Values = rngData.Cells(2, 1).Resize(rngData.Rows.Count - 1)
.XValues = rngData.Cells(2, 2).Resize(rngData.Rows.Count - 1)
End With
End Sub

This expert wasn't self-proclaimed, was he?

- Jon
 
V

vandenberg p

While I am sure the macro will work you don't need it. Click on the chart
wizard "without" selecting a series. Choose the kind of chart you want,
click next. A box opens with two tabs and a data range window. Ignore the
data range window and click on the series tab. When the next window opens
choose add. A new window opens with three input boxes. One for name , one
for the x variable and one for the y variable. Navigate to the data. The x
and y variables do not have to be in any order, or next to each other or
even on the same sheet. Simple choose the data and click finish. You've
got your chart.

Pieter Vandenberg

: Rob -

: You do this a lot, build your chart the wrong way? Here's a macro that
: lets you select your data (Y in the first column, X in the second) and
: build a line chart.

: Sub AddChartYX()
: '' Select 2-column range for chart

<snip>

: - Jon
: -------
: Jon Peltier, Microsoft Excel MVP
: http://www.geocities.com/jonpeltier/Excel/index.html
: _______


: Rob wrote:
:> Thanks allot, I now have it working.
:>
:> ps. the person who said, it could not be done, is a Excel Expert in a big
:> company?
:>
:> Rob
:>
:> :>
:>>I have 2 columns of data A1 B1 10 rows down
:>>
:>>I want to create a line chart using column A as the Y axis and column B as
:>>the X axis
:>>have been told this is not possible, is that right?
:>>
:>>Thanks Rob.
:>>
:>>
:>
:>
:>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top