Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Works when stepped-through, but errors when macro ran

I use the following code to create a line chart. This is a small part
of a much larger macro. In fact, it is but a small part of a
subroutine that is called by an even larger subroutine. The problem is
in referencing the source data for the chart.

Worksheets("Baseline Data").Activate
LastBase = Worksheets("Baseline
Data").Range("A10").End(xlToRight).Column
'
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = "='Baseline Data'!R10C2:R10C" &
(LastBase - 1)
.SeriesCollection(1).Values = "='Baseline Data'!R54C2:R54C" &
(LastBase - 1)
.SeriesCollection(1).Name = "=""Baseline"""
.SeriesCollection(1).Border.Weight = xlThick

When I run the subroutines, the reference to the "Baseline Data" sheet
doesn't come through. That is the chart source data is
=#REF!R10C11:R10C16. Interestingly, when I step through the code it
works.

Any thoughts?

Thanks,
John

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Works when stepped-through, but errors when macro ran


Have you tried declaring all your variables? This sometimes helps when
step through and run behave differently. Not completely sure why....


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=544022

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Works when stepped-through, but errors when macro ran

John, make certain you have application.screenupdating = true as some chart
statements only work when it is true. When you are stepping throught the
code, screenupdating is always on, thus the reason it works in step through
mode.

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

wrote in message
oups.com...
I use the following code to create a line chart. This is a small part
of a much larger macro. In fact, it is but a small part of a
subroutine that is called by an even larger subroutine. The problem is
in referencing the source data for the chart.

Worksheets("Baseline Data").Activate
LastBase = Worksheets("Baseline
Data").Range("A10").End(xlToRight).Column
'
Charts.Add
ActiveChart.ChartType = xlXYScatterLines
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues = "='Baseline Data'!R10C2:R10C" &
(LastBase - 1)
.SeriesCollection(1).Values = "='Baseline Data'!R54C2:R54C" &
(LastBase - 1)
.SeriesCollection(1).Name = "=""Baseline"""
.SeriesCollection(1).Border.Weight = xlThick

When I run the subroutines, the reference to the "Baseline Data" sheet
doesn't come through. That is the chart source data is
=#REF!R10C11:R10C16. Interestingly, when I step through the code it
works.

Any thoughts?

Thanks,
John



Reply
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
VBA errors in 2007 (works fine in 2003) Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 14 September 6th 09 12:46 PM
REF errors when opening excel in xp. works fine when opening wor. br Excel Discussion (Misc queries) 6 September 13th 05 11:41 AM
Stepped Functions Gary T Charts and Charting in Excel 2 June 14th 05 11:13 AM
Stepped fee calculation Betty Csehi Excel Discussion (Misc queries) 2 May 27th 05 09:53 PM
RPC ERROR - 1ST TIMES WORKS FINE - 2ND TIME ERRORS OUT PoK Excel Programming 0 August 5th 03 08:51 PM


All times are GMT +1. The time now is 01:08 PM.

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"