LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default 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 Whe=xlLocationAsObject, _
Name:=ws.Name
ActiveChart.HasLegend = False
End Sub
'==============================

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 Whe=xlLocationAsObject, Name:="Sheet1"
ActiveChart.HasLegend = False
End Sub



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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro relative referencing harriet Excel Discussion (Misc queries) 5 February 15th 05 01:40 PM
Record Macro Relative does not work? lbbss Excel Discussion (Misc queries) 3 December 13th 04 08:43 PM
Record Macro Relative does not work? lbbss Excel Discussion (Misc queries) 1 December 13th 04 07:55 PM
Relative referencing Dave Peterson[_3_] Excel Programming 0 August 21st 04 12:37 AM
missing macro absolute/relative referencing toolbar Alex[_20_] Excel Programming 2 March 2nd 04 05:48 PM


All times are GMT +1. The time now is 11:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"