Macro Relative Reference problem

A

ajpowers

I've been trying to record a macro that has the relative referenc
option selected. For example I have two data tables with exac
formatting, but different sales information. Before I start recordin
the macro I click one cell below of where my data table is, then
start recording and at that point I click the relative reference butto
and perform the functions of making a graph. Then I hit sto
recording. However, when I go one cell below my second data table an
run the macro, it goes back and uses the first data table'
information.

How do I fix this
 
J

JulieD

Hi

if you would like to copy & paste the code in your macro in a reply-post so
we can see it (to get to the code - tools / macro / macros - click on your
macro - choose EDIT - copy everything between the
Sub yourmacroname() and End Sub) - it might help.

Cheers
JulieD
 
A

ajpowers

Here is the macro:

Sub Macro6()
'
' Macro6 Macro
' Macro recorded 6/9/2004 by Amy Powers
'
' Keyboard Shortcut: Ctrl+c
'
ActiveCell.Offset(-1, 0).Range("A1").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet3").Range("A2:M5")
PlotBy:= _
xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet3"
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = True
ActiveChart.DataTable.ShowLegendKey = True
End Su
 
J

JulieD

Hi

if you look at the code it references "Sheet 3"

try the following
***********
Sub Macro6()

' Macro6 Macro
' Macro recorded 6/9/2004 by Amy Powers
'
' Keyboard Shortcut: Ctrl+c
'
dim cur_sheet

cur_sheet = activesheet.name

ActiveCell.Offset(-1, 0).Range("A1").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("" & cur_sheet &
"").Range("A2:M5"),PlotBy:= xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:=cur_sheet
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
ActiveChart.HasDataTable = True
ActiveChart.DataTable.ShowLegendKey = True
End Sub
********

cheers
JulieD
 
Top