Drawing a 2D graph with Excel

  • Thread starter nimmi_srivastav
  • Start date
N

nimmi_srivastav

My apologies for a truly newbie question. I want to know if there is
an Excel macro out there that has the same effect as the following
sequence of steps (for drawing a line graph)

1. Highlight Value (Y) axis data
2. Insert Chart
3. Standard Types -> Line
4. Next
5. Series tab
6. Category (X) axis labels
7. Provide the range of values (explicitly or by selection)
8. Next
9. Fill the Title, Category (X) axis and Value (Y) axis

Thanks,
NS
 
L

L. Howard Kittle

Hi NS,

From the macro recorder...

Sub Macro3()
Range("A1:B10").Select
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B10")
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
ActiveWindow.Visible = False
Windows("Book1.xls").Activate
Range("A1").Select
End Sub

HTH
Regards,
Howard
 
L

L. Howard Kittle

Forgot to record no. 9 on your list

Sub Macro4()

Range("A1:B10").Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B10"),
PlotBy _
:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "This A Chart"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "How many"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "When"
End With
ActiveWindow.Visible = False
Windows("Book1.xls").Activate
Range("A1").Select
End Sub
 

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