LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Problem adding charts using Do-Loop Until loop

Hi Greg,

Thanks very much for replying. I was wondering at the back of my mind when I
posted this whether or not the length of the code would put people off, so
thanks very much for taking the time and trouble to try and decipher it.

Fortunately, I've managed to solve the problem. I was doing more research
online this morning and by chance came across a comment from Jon Peltier.
Apparently, when the Charts.Add command adds a new chart sheet to a workbook
it sometimes adds an empty series to it, thus making the standard empty chart
area appear, and sometimes it doesn't, hence just leaving the white space of
the chart sheet. So first time through the Do-While loop the former was
occurring and second time through the latter was occurring. The solution is
to add the following immediately below the Charts.Add command:

If ActiveChart.SeriesCollection.Count = 0 Then
ActiveChart.SeriesCollection.NewSeries
End If

The way the macro adds series to the charts depends on a number of factors
related to the nature of the data being plotted and the way the data
worksheet is set up. The worksheet isn't terribly simple and, since I'm
pretty new to VBA, this was the only way I could come up with to give the
code the necessary 'decision-making' capabilities. However, I'd love to know
how to improve the efficiency of my coding, so do you have any general
pointers on sections of code that I should be looking to improve?

Cheers,

Chris

--
Chris


"Greg Wilson" wrote:

Chris,

I had a look at your post earlier but gave up trying to figure out what you
were trying to do. IMHO, the problem is that the code is very long and there
is a lot of selecting and offseting going on and we have to infur what is
happening without having any idea how the worksheets are strucured. There is
also a lot of inefficiency in the code and it really needs a major revamp.

Since at this point it seems unlikely that anyone will respond, suggested is
that you provide a simplified version of the worksheet layout as well as a
description of what it is you are trying to do. Keep it simple. Expect
responders to only provide the required code structure and adapt it to suit.
And don't expect responders to supply all the chart formatting detail. Flesh
it out yourself. This is just my own opinion granted.

Best regards,
Greg


 
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
Adding criteria to loop Andyjim Excel Worksheet Functions 0 January 13th 08 08:54 PM
Use a loop to create multiple Charts - Suggestions ? APOEL Charts and Charting in Excel 1 July 29th 06 03:36 AM
Adding in loop Sally Mae Charts and Charting in Excel 1 July 5th 06 01:34 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
Loop through sheets, deselect charts Daniel Bonallack[_2_] Excel Programming 4 October 28th 03 07:27 PM


All times are GMT +1. The time now is 05:15 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"