+ Reply to Thread
Results 1 to 4 of 4

Relative referencing in macro won't work

  1. #1

    Relative referencing in macro won't work

    Hello:

    I have been recording a macro to automate the creation of some charts.
    Pressing the "Relative Referencing" button does not create a relative
    referenced macro.

    I am a user without admin privileges on a w2k computer using Excel
    2000. Could it be that not having the admin privileges is causing the
    problem? If so, is there a work around?

    Thanks,

    Ahmet Toprak


  2. #2
    Debra Dalgleish
    Guest

    Re: Relative referencing in macro won't work

    What type of reference are you getting in the code?
    Can you post a few lines of the recorded code, and describe what you're
    trying to achieve?

    [email protected] wrote:
    > Hello:
    >
    > I have been recording a macro to automate the creation of some charts.
    > Pressing the "Relative Referencing" button does not create a relative
    > referenced macro.
    >
    > I am a user without admin privileges on a w2k computer using Excel
    > 2000. Could it be that not having the admin privileges is causing the
    > problem? If so, is there a work around?
    >
    > Thanks,
    >
    > Ahmet Toprak
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


  3. #3

    Re: Relative referencing in macro won't work

    Hello Debra:

    Here is what I got. I want to be able to place my cursor on, say, cell
    A1, then plot the data in cells A1 through O1. Next place the cursor on
    A2, and plot A2 through O2. So on, so forth.

    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 2/2/2005 by toprak
    '

    '
    ActiveCell.Range("A1:O1").Select
    Charts.Add
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A2:O2"),
    PlotBy:= _
    xlRows
    ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
    ActiveChart.HasLegend = False
    End Sub


  4. #4
    Debra Dalgleish
    Guest

    Re: Relative referencing in macro won't work

    The selection was recorded as a relative reference, but the chart source
    isn't. You can modify the recorded code slightly, and it will create a
    chart for the row you have selected in column A:

    '===========================
    Sub Macro1()
    '
    Dim rng As Range
    Dim ws As Worksheet
    '
    Set rng = ActiveCell.Range("A1:O1")
    Set ws = ActiveSheet
    Charts.Add
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData _
    Source:=rng, PlotBy:=xlRows
    ActiveChart.Location Where:=xlLocationAsObject, _
    Name:=ws.Name
    ActiveChart.HasLegend = False
    End Sub
    '==============================

    [email protected] wrote:
    > Hello Debra:
    >
    > Here is what I got. I want to be able to place my cursor on, say, cell
    > A1, then plot the data in cells A1 through O1. Next place the cursor on
    > A2, and plot A2 through O2. So on, so forth.
    >
    > Sub Macro1()
    > '
    > ' Macro1 Macro
    > ' Macro recorded 2/2/2005 by toprak
    > '
    >
    > '
    > ActiveCell.Range("A1:O1").Select
    > Charts.Add
    > ActiveChart.ChartType = xlLine
    > ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A2:O2"),
    > PlotBy:= _
    > xlRows
    > ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
    > ActiveChart.HasLegend = False
    > End Sub
    >



    --
    Debra Dalgleish
    Excel FAQ, Tips & Book List
    http://www.contextures.com/tiptech.html


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1