Auto Scale Chart Macro -- Any improvements please?

This is the best way I've found to correctly scale a chart -- the only way I 
found to exclude a chart interpolating with #NA cells was to delete those 
cells containing #NA, and run the chart.  This takes a long time on my 
computer.  Wondering if there is a better way.  This macro is directly taken 
from 2 excel mvps and modified; i believe a mehta and ron bovarty, but could 
be wrong.  Thanks for taking a look.  

Sub AutoScaleYAxes()
    Dim ValuesArray(), SeriesValues As Variant
    Dim Ctr As Integer, TotCtr As Integer
    
    Application.Run "Extend_Stock_Data"
    Application.Run "Delete_Row_NA_Data"
    
    Sheets("SnapShot").Select
    ActiveSheet.ChartObjects("CIQChart1s0t0").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.Visible = False
    
    With ActiveChart
    On Error Resume Next
        For Each X In .SeriesCollection
            SeriesValues = X.Values
            ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
            For Ctr = 1 To UBound(SeriesValues)
                ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
            Next
            TotCtr = TotCtr + UBound(SeriesValues)
        Next
        .Axes(xlValue).MinimumScaleIsAuto = True
        .Axes(xlValue).MaximumScaleIsAuto = True
        .Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
        .Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
    End With
End Sub


Sub Delete_Row_NA_Data()
    Dim DeleteValue As String
    Dim rng As Range

  Sheets("data").Select
    DeleteValue = "#N/A"
    With ActiveSheet
        .Range("D100:D1000").AutoFilter Field:=1, Criteria1:=DeleteValue
        With ActiveSheet.AutoFilter.Range
            On Error Resume Next
            Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
                      .SpecialCells(xlCellTypeVisible)
            On Error GoTo 0
            If Not rng Is Nothing Then rng.EntireRow.Delete

        End With
        .AutoFilterMode = False
    End With
End Sub

Sub Extend_Stock_Data()


Dim LastRow As Long


With Worksheets("data")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
..Range("b17:g17").AutoFill Destination:=.Range("b17:g" & LastRow) _
, Type:=xlFillDefault

End With

End Sub
0
SteveC1 (18)
2/15/2007 9:00:35 PM
excel.charting 18370 articles. 0 followers. Follow

2 Replies
1431 Views

Similar Articles

[PageSpeed] 36

I'm betting that the code is about as good as it gets.  I just finished a 
battle with 2007 charts also, and kind of feel like I lost <g>.  You said "it 
takes a long time on my computer" and that's exactly the experience I had: 
charting on two separate systems takes up to 12 times as long in Excel 2007 
to complete as it does for same data and same chart type in Excel 2003 on a 
machine much slower than either of the two running 2007.

To give specifics: generating 51 charts, 49 with 8800 data points, 2 with 
1320 data points.  X-Y Scatter chart.
AMD 3200+ 1GB single core w/Excel 2003: 1m 21s to complete
AMD X2 4800+ 2GB dual-core w/Excel 2007: 12m 05s to complete!
Intel E6600 2GB 'CoreDuo' w/Excel 2007: 11m 47s to complete!

After finishing the charting, system response in Excel is snail-slow.

Also, are you seeing anything during the changing of the charts with 
ActiveWindow.Visible=False ??
I was using Application.ScreenUpdating=False and the charting process forces 
its way through that in Excel 2007, where it did not in 2003. 

"SteveC" wrote:

> This is the best way I've found to correctly scale a chart -- the only way I 
> found to exclude a chart interpolating with #NA cells was to delete those 
> cells containing #NA, and run the chart.  This takes a long time on my 
> computer.  Wondering if there is a better way.  This macro is directly taken 
> from 2 excel mvps and modified; i believe a mehta and ron bovarty, but could 
> be wrong.  Thanks for taking a look.  
> 
> Sub AutoScaleYAxes()
>     Dim ValuesArray(), SeriesValues As Variant
>     Dim Ctr As Integer, TotCtr As Integer
>     
>     Application.Run "Extend_Stock_Data"
>     Application.Run "Delete_Row_NA_Data"
>     
>     Sheets("SnapShot").Select
>     ActiveSheet.ChartObjects("CIQChart1s0t0").Activate
>     ActiveChart.PlotArea.Select
>     ActiveWindow.Visible = False
>     
>     With ActiveChart
>     On Error Resume Next
>         For Each X In .SeriesCollection
>             SeriesValues = X.Values
>             ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
>             For Ctr = 1 To UBound(SeriesValues)
>                 ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
>             Next
>             TotCtr = TotCtr + UBound(SeriesValues)
>         Next
>         .Axes(xlValue).MinimumScaleIsAuto = True
>         .Axes(xlValue).MaximumScaleIsAuto = True
>         .Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
>         .Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
>     End With
> End Sub
> 
> 
> Sub Delete_Row_NA_Data()
>     Dim DeleteValue As String
>     Dim rng As Range
> 
>   Sheets("data").Select
>     DeleteValue = "#N/A"
>     With ActiveSheet
>         .Range("D100:D1000").AutoFilter Field:=1, Criteria1:=DeleteValue
>         With ActiveSheet.AutoFilter.Range
>             On Error Resume Next
>             Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
>                       .SpecialCells(xlCellTypeVisible)
>             On Error GoTo 0
>             If Not rng Is Nothing Then rng.EntireRow.Delete
> 
>         End With
>         .AutoFilterMode = False
>     End With
> End Sub
> 
> Sub Extend_Stock_Data()
> 
> 
> Dim LastRow As Long
> 
> 
> With Worksheets("data")
> LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
> .Range("b17:g17").AutoFill Destination:=.Range("b17:g" & LastRow) _
> , Type:=xlFillDefault
> 
> End With
> 
> End Sub
0
Utf
2/17/2007 3:25:08 PM
This can be cleaned up:

    Sheets("SnapShot").Select
    ActiveSheet.ChartObjects("CIQChart1s0t0").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.Visible = False

    With ActiveChart

use this instead:

    With Sheets("SnapShot").ChartObjects("CIQChart1s0t0")

I don't know how much it will help with 2007. I have yet to do any 
large-scale charting in 2007, just small bits to find workarounds for one of 
my clients.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"SteveC" <SteveC@discussions.microsoft.com> wrote in message 
news:52DB03DB-74AA-46BA-B13F-2CDD55DAC679@microsoft.com...
> This is the best way I've found to correctly scale a chart -- the only way 
> I
> found to exclude a chart interpolating with #NA cells was to delete those
> cells containing #NA, and run the chart.  This takes a long time on my
> computer.  Wondering if there is a better way.  This macro is directly 
> taken
> from 2 excel mvps and modified; i believe a mehta and ron bovarty, but 
> could
> be wrong.  Thanks for taking a look.
>
> Sub AutoScaleYAxes()
>    Dim ValuesArray(), SeriesValues As Variant
>    Dim Ctr As Integer, TotCtr As Integer
>
>    Application.Run "Extend_Stock_Data"
>    Application.Run "Delete_Row_NA_Data"
>
>    Sheets("SnapShot").Select
>    ActiveSheet.ChartObjects("CIQChart1s0t0").Activate
>    ActiveChart.PlotArea.Select
>    ActiveWindow.Visible = False
>
>    With ActiveChart
>    On Error Resume Next
>        For Each X In .SeriesCollection
>            SeriesValues = X.Values
>            ReDim Preserve ValuesArray(1 To TotCtr + UBound(SeriesValues))
>            For Ctr = 1 To UBound(SeriesValues)
>                ValuesArray(Ctr + TotCtr) = SeriesValues(Ctr)
>            Next
>            TotCtr = TotCtr + UBound(SeriesValues)
>        Next
>        .Axes(xlValue).MinimumScaleIsAuto = True
>        .Axes(xlValue).MaximumScaleIsAuto = True
>        .Axes(xlValue).MinimumScale = Application.Min(ValuesArray)
>        .Axes(xlValue).MaximumScale = Application.Max(ValuesArray)
>    End With
> End Sub
>
>
> Sub Delete_Row_NA_Data()
>    Dim DeleteValue As String
>    Dim rng As Range
>
>  Sheets("data").Select
>    DeleteValue = "#N/A"
>    With ActiveSheet
>        .Range("D100:D1000").AutoFilter Field:=1, Criteria1:=DeleteValue
>        With ActiveSheet.AutoFilter.Range
>            On Error Resume Next
>            Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
>                      .SpecialCells(xlCellTypeVisible)
>            On Error GoTo 0
>            If Not rng Is Nothing Then rng.EntireRow.Delete
>
>        End With
>        .AutoFilterMode = False
>    End With
> End Sub
>
> Sub Extend_Stock_Data()
>
>
> Dim LastRow As Long
>
>
> With Worksheets("data")
> LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
> .Range("b17:g17").AutoFill Destination:=.Range("b17:g" & LastRow) _
> , Type:=xlFillDefault
>
> End With
>
> End Sub 


0
jonxlmvpNO (4558)
2/19/2007 6:35:40 PM
Reply:

Similar Artilces:

Dynamic Chart Question #3
Hi All, I'm trying to set up line charts for more than 40 different production locations. But I would like to give the user the option of selecting one or two (at most) locations then have Excel display the corresponding chart/s instead of creating 40+ charts. Each location will have its own data table (pounds/dollars). How do I go about doing this task? Thanks. -- when u change the way u look @ things, the things u look at change. Hi, For information on dynamic charts and controlling which series are displayed have a look at Jon's page. http://peltiertech.com/Excel/Charts/Dy...

Auto Filter problem
I am using the auto filter for a particular column to sort out differen medical programs. When I click the drop down and click a program, i doesnt show me ALL the lines that say this particular program. Why is this? -- Message posted from http://www.ExcelForum.com Hi maybe some hidden characters in these lines 8e.g. additional space characters, etc.) -- Regards Frank Kabel Frankfurt, Germany "jkb724 >" <<jkb724.19rasx@excelforum-nospam.com> schrieb im Newsbeitrag news:jkb724.19rasx@excelforum-nospam.com... > I am using the auto filter for a particular column to so...

Auto-Editing
Word 2003 has a very annoying default. It assumes too much! If I reformat a few words in a document, it changes the entire document to that formatting. Grr-rrr-r! I have to constantly press undo to get what I want. I know there's a feature that's causing this annoyance but I can't find it to turn it off! Can anyone help, please? See http://word.mvps.org/faqs/formatting/wholedocumentreformatted.htm. -- Stefan Blom Microsoft Word MVP "Connie Martin" <ConnieMartin@discussions.microsoft.com> wrote in message news:CD959D82-F81B-4A9D-993E-73...

showing data values on chart
in excel when mouse stand on chart,excel is showing the data values of that point.how can to do this action in access? Exactly the same. When you hover the mouse over a data point for a little amount of time, a yellow bow should come up describing what's in your data point. -- Regards, Steve "afshin" wrote: > in excel when mouse stand on chart,excel is showing the data values of that > point.how can to do this action in access? Where you insert chart?i insert chart on report,and i can't to see data value on data point. "Steve"...

Exporting Excel Charts in Separate Tabs
I have an excel file with different charts on each tab. The Excel file has at least 20 tabs and I would like to export them into Word as a separate sheet per tab for a reference guide. Is there a way to export from excel without having to cut and paste each tab? I am using MS Office 2003. ...

Not plot zero on line chart without using NA?
Is there any way to have a line chart ignore the zeros other than manipulate the formula to show NA? If there were, would we settle for using NA()? We've been asking for something better for several versions of Excel. There are two options: use NA() in the formula, or delete the formula altogether. - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltiertech.com/ Homer wrote: > Is there any way to have a line chart ignore the zeros other than manipulate > the formula to show NA? > > That's what I thought, but I figured I'd take a shot at ...

Auto-Calculate
I have a spreadsheet that utilize the stock quote add-in from MSN. On a daily basis I refresh the add-in functions for the Highs, Lows, Last, Volume, etc. On occasion the spreadsheet reverts to manual caculation settings, and I have to press the F9 even after I updated the quotes. I've always preferred the any spreadsheets I open, blank or otherwise, the automatic setting selected for calculations. I consider this an annoyance. Has anyone experienced this glitch? Is there a fix for it? Ron_D Ron Excel takes the calculation mode from the first workbook that opens in a session. Sub...

Doing charts in Excel 2000
i am still using the Excel in my Office 200 package. Where can I get udates to do better charts? All of the techniques shown here http://peltiertech.com/Excel/Charts/index.html can be used to make more interesting chart best wishes -- Bernard V Liengme Microsoft Excel MVP www.stfx.ca/people/bliengme remove caps from email "TVG" <TVG@discussions.microsoft.com> wrote in message news:CD14A74C-8018-40FC-AA4F-FA0925208A78@microsoft.com... >i am still using the Excel in my Office 200 package. Where can I get udates > to do better charts? ...

auto copy self
How do I arrange for Outlook to automatically copy myself on every new, reply or forward email? If you mean keep a copy of all sent, see settings under Tools/Options/Email Options and Advanced Options David "rich" <steamuk@aol.com> wrote in message news:055c01c3664f$dadecd30$a001280a@phx.gbl... > How do I arrange for Outlook to automatically copy myself > on every new, reply or forward email? ...

How can I hide tasks in a Gantt chart?
I only want to hide certain tasks - not all tasks at a given level On Thu, 28 May 2009 02:06:06 -0700, lberry <lberry@discussions.microsoft.com> wrote: >I only want to hide certain tasks - not all tasks at a given level Create a new layer called "Hidden" Open the drawing explorer window and go through all the shapes to find the ones for the appropriate task and assign these shapes to the hidden layen and remove them from the Gantt layer. Now make the Hidden layer non-visible. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.electronics.sandr...

Macro help
I had a macro in my workbook and deleted it b/c I did not want it anymore. Now whenever I open the workbook it prompts me to enable or disable the macro even though I have deleted it from the Tools menu. Any help on how to get rid of this? Hi Meredith Look here http://www.contextures.com/xlfaqMac.html#NoMacros -- Regards Ron de Bruin http://www.rondebruin.nl "Meredith" <anonymous@discussions.microsoft.com> wrote in message news:205f701c45923$e1d470a0$a401280a@phx.gbl... > I had a macro in my workbook and deleted it b/c I did not > want it anymore. Now wheneve...

Chart Automatically Updating
I have set up a chart that automatically updates as new data is entered into the spreadsheet. The problem is....I would like to copy this worksheet so that there are 9 different worksheets (of this same set-up only with different names) in the same workbook. What is the correct way for me to make copies of worksheet, so that my chart in each worksheet still automatically updates based off of what is entered in that worksheet? The directions I used for setting up my original worksheet is located at http://peltiertech.com/Excel/Charts/DynamicCharts.html Maybe this only works for on...

Excel macro & MS XP OS trouble
I have recently switched from the MS NT operating system to the MS XP Professional os. My problem is I have an Excel macro that used to work with the NT system and now it does not with XP. Everytime I try to submit my Excel form I now get the following error message: "A document with the name '<name of file>' is already open. You cannot open two documents with the same name, even if the documents are in different folders. To open the second document either close the document that currently open, or renmae one of the documents." I have tried to rename the excel...

Hyperlink to and from a Chart
I have a data page, with lots (20) of tables on it. I have a graph for each table, on their own pages. I would like to have a hyperlink (or something similar) so that at the bottom of each table, I could have "Click here to go to Graph 1", and then jump to the correct graph. On the graph page, I would like a button enabling me to return to the data page. Hyperlinks (in reading the Help file) need an address to jump to, but what is the address of a Graph ? I can't use the Name Box to give it a defined name, and am stuck. Any suggestions please. Thanks, Rob Lepper Hello there...

Auto correct or Auto complete
We are all familiar witht he auto correct or auto complete functions found in MS applications. Of course that means it is available in Access also. My question is this ... can this function be replicated within the DB, so that the set of auto correct items are part of the package rather than something that would have to be set up on each individual desktop system? It's use, for me, would primarily be within a memo field where medical abreviations, used as a shortcut, would convert to the true meaning as the user types them in. Ex: "prn" without quotes would change to. &qu...

Auto Scale Chart Macro -- Any improvements please?
This is the best way I've found to correctly scale a chart -- the only way I found to exclude a chart interpolating with #NA cells was to delete those cells containing #NA, and run the chart. This takes a long time on my computer. Wondering if there is a better way. This macro is directly taken from 2 excel mvps and modified; i believe a mehta and ron bovarty, but could be wrong. Thanks for taking a look. Sub AutoScaleYAxes() Dim ValuesArray(), SeriesValues As Variant Dim Ctr As Integer, TotCtr As Integer Application.Run "Extend_Stock_Data" Applic...

Help on SUMIF please!
Hi, I have a spreadsheet where I am trying to insert a function in a cel which would say: 'Display the sum of cells B5, C8 and B10. If the value contains th NA() function, discount it and display the sum of the other values.' I have tried using SUMIF but cannot get the cell to display correctly what should I enter for this function? Thanks -- Message posted from http://www.ExcelForum.com You probably have to use something like =IF(ISNA(B5),0,B5)+IF(ISNA(C8),0,C8)+IF(ISNA(B10),0,B10) given that you use NA(), if the #N/A comes from an error in a formula and not willingly you could ...

data missing in charts original file 97-2003 opened 2007 and then.
I have a file that is created in 97-2003, after it is opened in excel 2007 and then saved back to 97-2003 version when it is reopened the charts that are included are not showing any of the text data or information that was added to the charts. Anyone else have this problem or know how to fix it other than manually updating the charts. Did you add the information with XL2007? If so maybe you used components that are available only in that version. Did you get a warning that saving in the older format will lead to loss of information? If you don't remember you may want to go thr...

Pivot Chart problems
This is a multi-part message in MIME format. ------=_NextPart_000_00B3_01C4E370.755D7D40 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable I have two issues with pivot charts. 1) I create a pivot table and chart with VB. I want thick lines on the = chart, so I do as follows: For i =3D 1 To .SeriesCollection.Count .SeriesCollection(i).Select With Selection.Border .Weight =3D xlThick End With Next This works great. However, upon selecting a Page Field value from the =...

OWA auto login
I am trying to use the credentials from the forms authentication login to automaticaly log in to Outlook Web. I redirect to a URL with this format: http://UserName:Password@mailserver/exchange I have seen this example in other posts but this does not work for me. I still get the Outlook Windows Login prompt. Perry Perecli Manole wrote: > I am trying to use the credentials from the forms authentication > login to automaticaly log in to Outlook Web. I redirect to a URL with > this format: http://UserName:Password@mailserver/exchange > I have seen this example in other posts but t...

When launching Outlook I recieve the following error... please he
When launching Outlook 2003 I recieve the following error: The add-in "C:\PROGRAM~1\SPAMBL~1\Bin\461~1.0\SBOLExt.dll" could not be installed or loaded. This problem may be resolved by using Detect and Repair on the Help menu. I ran the Detect and Repair and that didn't work. I ran the repair option from Add and Remove Program in Control Panel and that didn't work. I also un-installed and then re-installed Outlook 2003 and that didn't work. I'm running Windows 2000. Any ideals...? Did you have something possibly called SpamBlocker installed at some point?...

Auto look through subfolders
Please help. I can write a macro that will extract data from all excel files in a specific folder. What I need to be able to do is write a macro that will automatically extract data from excel files within folders and sub folders and sub sub folders etc For example the data is all held on the following directory: H:\development forms\2006 cost sheets\ And within that directory by customer - for example Tesco, Boots, Asda etc. These customers are then subdivided into product ranges - eg 1,2,3,4 etc and some futher subdivided by national or exclusive. All the excel files are in exactly th...

macro help = extract content of specific columns accross a row
have a spreadsheet which consists of about 5125 rows and 2840 columns. I am using Excel 2007 in order to get access to the extra columns. Now I need help creating a macro to automate a very tedius and manual task. The first column in the spreadsheet is empty. What I Need =========== For every row I would like to extract the contents of certain columns accross the row and copy to the first column of the row. into the first column i would like to copy the contents of the following columns accross the row. 6C = sixth column, 9C = 9th column etc... 6C + " " + 7C + " &...

SAVE FILE
I have developed a file with a macro which is protected by a password. A "Save" button with the assigned macro calls the procedure in the macro and when I am trying to save a file the following message appears "You cannot save this file format when the VBA Project is protected You may unprotect the VBA Project by......" What do you suggest I do to save a file with a protected macro? The macro must be protected, it is very important for me not to allow access to the macro in totallity. I am using certain cells' information to name the file My code lo...

Any way to get rid of an auto-suggestion in the login dialog box, for Exchange/OL using RPC over HTTP?
A client was using RPC over HTTP to two different Exchange servers (OL prompting for profile on startup). Both profiles were set up to prompt for credentials upon connection to Exchange. There's now only one Outlook profile needed; the other is gone and OL isn't prompting for the profile selection any longer, which is fine. However, Outlook is remembering domain1\user and domain2\user in the login dialog box, and I'd love to be able to get rid of the no-longer-valid credential dropdown suggestion. (The computer is not a member of a domain and hence always needs to be prom...