Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to use a macro to make a line graph of certain cells within
my worksheet (Excel 2004:mac). The data will always be 143 rows. I want to be able to select the starting cell, and have the macro automatically select the 142 rows below it and create a line graph. I have tried using relative referencing within my macro, but the graph that is created always results in my original selected data being graphed. I made sure relative referencing is selected. What am I doing wrong? This is the code that is generated from my macro: Sub Macro4() ActiveCell.Range("A1:A143").Select Charts.Add ActiveChart.ChartType = xlLine ActiveChart.SetSourceData Source:=Sheets("data").Range("G79:G221"), PlotBy _ :=xlColumns ActiveChart.Location Whe=xlLocationAsNewSheet With ActiveChart .HasTitle = False .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False End With End Sub I found an earlier thread that talked about this same situation but I could not get it to work. This was the code that was suggested: Sub Macro1() Dim r As Range Dim s As String Set r = ActiveCell.Resize(10,0) s = ActiveCell.Parent.Name Charts.Add ActiveChart.ChartType = xlLineMarkersStacked ActiveChart.SetSourceData Source:=r ActiveChart.Location Whe=xlLocationAsObject, Name:=s End Sub I got a syntax error when trying this out... Thanks for the help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro using relative references | Excel Worksheet Functions | |||
Help with converting a block of cells with Absolute and mixed references to relative references | Excel Worksheet Functions | |||
macro vba relative references | Excel Worksheet Functions | |||
relative cell references in vba macro | Excel Programming | |||
Making a macro references relative | Excel Programming |