Limiting Chart Series with a Macro

Good Day,

Does anyone know how to change the max limit on the x-axis 
of a chart with a macro? In other words say I have data 
of  rainfall vs time for different countries. Some may 
have for 10 yrs and other may have for 50. How can I use a 
macro so that the x-axiswould end on the last date for all 
graphs?

Any Ideas
Many Thanks
Llednar
0
randellj1 (2)
9/16/2003 8:59:14 PM
excel.charting 18370 articles. 0 followers. Follow

2 Replies
684 Views

Similar Articles

[PageSpeed] 40

Randell -

This macro finds the largest X max on all of the charts on the active 
sheet, then applies this to all of these charts.

Sub SameXMax()
Dim ChtOb As ChartObject
Dim dXMax As Double
For Each ChtOb In ActiveSheet.ChartObjects
     ' Find largest X max
     dXMax = WorksheetFunction.Max(dXMax, _
         ChtOb.Chart.Axes(xlCategory).MaximumScale)
Next
For Each ChtOb In ActiveSheet.ChartObjects
     ' Apply largest X max to all charts
     ChtOb.Chart.Axes(xlCategory).MaximumScale = dXMax
Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
http://www.geocities.com/jonpeltier/Excel/index.html
_______

Llednar wrote:
> Good Day,
> 
> Does anyone know how to change the max limit on the x-axis 
> of a chart with a macro? In other words say I have data 
> of  rainfall vs time for different countries. Some may 
> have for 10 yrs and other may have for 50. How can I use a 
> macro so that the x-axiswould end on the last date for all 
> graphs?
> 
> Any Ideas
> Many Thanks
> Llednar

0
jonpeltier (303)
9/17/2003 3:46:46 AM
[This followup was posted to microsoft.public.excel.charting and a copy 
was sent to the cited author.]

In addition to Jon's suggestion, check the AutoChart Manager, a free 
add-in available from my website. 

-- 
Regards,

Tushar Mehta
MS MVP Excel 2000-2003
www.tushar-mehta.com
Excel, PowerPoint, and VBA tutorials and add-ins
Custom Productivity Solutions leveraging MS Office


In article <04b901c37c95$62ca6af0$a301280a@phx.gbl>, randellj1
@hotmail.com says...
> Good Day,
> 
> Does anyone know how to change the max limit on the x-axis 
> of a chart with a macro? In other words say I have data 
> of  rainfall vs time for different countries. Some may 
> have for 10 yrs and other may have for 50. How can I use a 
> macro so that the x-axiswould end on the last date for all 
> graphs?
> 
> Any Ideas
> Many Thanks
> Llednar
> 
0
ng_poster (159)
9/21/2003 12:45:52 PM
Reply:

Similar Artilces:

Price History Chart
The data is here in Price History, why can't Money chart it for me? Am I missing something? for Money 2004? The default chart only shows a fixed time. If you right click and add the chart to your favorites, you should be able to customize the date range. -- Glyn Simpson, Microsoft MVP - Money http://money.mvps.org Check http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny for UK tips and fixes for MS Money. To send Microsoft your wishes or suggestions, use http://register.microsoft.com/mswish/suggestion.asp or http://www.microsoft.com/uk/support/money/feedback especially i...

Legend in x-y Scatter chart does not show marker
I have an Excel program, created with Excel 2002. All is fine. Transferred to Office 2007. Now, in the charts (x-y scatter charts with two data sets each) the data set markers do not show up in the legend. Is this a known Beta error? Am using Beta 2 Tech Refresh. Is there a work-around? Any help would be appreciated. Peter K. Hi, Markers not being displayed in the legend is a non bug that is reported fixed in the latest builds. Only work around I can think of, although I not at a pc I can test this on, is to build you own legend using data labels that display the legend key. Alt...

macro that runs only when workbook is created
Can anyone tell me if excel has this capability built in? I know in word you can create a autonew macro that only runs when the document is created (doesn=92t run when reopened). Is this possible in excel. Using excel 2007. I want to create a new workbook from a template and I would like to have a macro run when the workbook is created. Thanks for any advice. BRC You need to use Application level events. In the ThisWorkbook code module, paste the following: Private WithEvents App As Excel.Application Private Sub App_NewWorkbook(ByVal Wb As Workbook) MsgBox "New Work...

change axis info on radar charts
How do I get all axis on a radar chart to to display the axis numbers (for each axis individaully). Secondly, how does one get a radar chard with the various axis in different scales (ie Axis 1 scale 1 to 10, Axis2 scale 0 to 10 000, Axis3 scale 0 to 0.5) Alfred - Look for Radar Charts on Tushar Mehta's web site, http://tushar-mehta.com - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ alfred wrote: > How do I get all axis on a radar chart to to display the axis numbers (for > each axis i...

Chart-VBA add-in
I see a lot of geniuses giving advise and their web sites with excellent material. Why dont we all create "The" charting add-in? I got many useful routines and an interface for something I call the "Chart Loopster" [under development] but am too busy [software is my hobby, not profession] and do not have the incredible genius of the MVPs. Do you think you could seamlessly add to my book for absolute novices in Excel-- http://vgupta1000.tripod.com/Vol_1_2.zip ? Something on custom charts, dynamic charts, but nothing too complex... If there were one "genius", t...

Size of Chart-Save as Web Page
When I publish a chart as a web page (Excel 2003), the image is very large. I have tried changing the Screen Resolution in the Web Options but it does not seem to have any affect. Do others have this same problem, is there a work around? TIA Dean ...

Chart title text linked from a cell? Possible?
I would like to make a chart that has its title text linked to the contents of a cell. It is not obvious how to do this, or even if it is possible. It appears like the chart title is static -- you have to manually type in the title, even if it already, conveniently, exists in the contents of a cell somewhere. Is there a way to do it? I have a giant array of charts I am making and the titles are already written into the first column, it would be ncie to just link them into the title space. A second, but related question is, can I create text boxes within a chart, whose contents are defined...

Can a macro be made to work based on a formula? #2
Is it possible to have a macro run based on the answer to a question? If the answer to a certain question is yes then the macro would run. A formula in a worksheet cell can call a function written in VBA. But that function can only return a result to the cell containing the formula, just like the built-in functions like SUM and AVERAGE do. The code can't change other cells, do formatting, etc. On Tue, 25 Jan 2005 18:59:04 -0800, "lonnied" <lonnied@discussions.microsoft.com> wrote: >Is it possible to have a macro run based on the answer to a question? If the >ans...

Getting a line chart to NOT plot a zero value
I have a chart that is updated each month with new production figures and a line chart set up to automatically pull the data from the chart and plot it; however, on the months that haven't occurred yet, the line chart is plotting those months as "zero". I've tried setting the "plot empty cells as: not plotted" in tools/options/chart, but that doesn't work. Apparently, because there is a formula in the cell for the future months, it is plotting the zero... What am I missing?! Thanks a ton!! Formulas must return something. "" (which they pre...

Disabled Macro File
I purchased a new Dell computer last September 2002 with Windows XP Professional. The software is Office XP Small Business. My previous computer had Office 95. In the previous version of Excel I created macros in a file called LIBRARY.XLM. Excel opens the files in XLSTART directory when starting. I put LIBRARY.XLM in the XLSTART directory on my new computer. Starting Excel the file opened and executed some macros automatically(i.e. Auto Open). Something happened and the security disabled this macro file. The file does not load automatically. The only way to load this file is to open ...

how do i change chart legend entry in Excel?
Now it says "series 1" or similar and I can't figure out how to change it to the description that exists in a particular cell. Click once on the chart (activate it). The standard toolbar should show an option called "Chart". Click on "Chart" -> "Source Data". In the "Source Data" dialog box go to the "Series" tab. You can reference the cell that you want for the legend description via the "Name" input area. Or, you can type the name into that area to manually input it. -- John Mansfield "basm...

Exchange2003 backup folder limits at 2GB
Hi, Microsoft Windows Server 2003 Standard Edition + SP1 Exchange Server 2003 (Version 6.5 Build 7226.6: Service Pack 1) My boss loves to keep all mails in his inbox and its size is around 3GB then my backup software (Legato Networker) cannot backup his mailbox. Legato's support person said that it has to extract every folders to .PST file before backing it up but somehow the limit is still at 2GB. He said that the problem is somewhere on the Exchange engine that it still uses the old version of the .PST Is this true? Is there any method of getting beyond 2GB? Tha...

dont show zero vaules in a chart
I have a chart that is tracking sales for the month, (by day) the chart has Zero values due to an "IF" statment that has a false or the reference cell is not yet filled in resulting in a "zero value" the chart has a trend line that is tending based on all the remaining zero values . I have changed the Chart options to not display zeros, but this doesnt solve it. Hi, In your formula use the function NA() instead of False. Cheers Andy Donald Watkins wrote: > I have a chart that is tracking sales for the month, (by day) the chart has > Zero values due to an &q...

How do I enable macros in a spreadsheet when I first open it?
I have a spread sheet with print macros and in the past when I opened it I would be asked if I wanted to enable macros. Now I don't get that question and the macros do not work. I get an error message telling me that the macros are disabled. This has happened after I have loaded Office 2000 updates. In the TOOLS menu go to MACRO then SECURITY. In here you can change the macro security level - MEDUIM level is goo as you can choose to enable or disable macros in a workboo -- LB7 ----------------------------------------------------------------------- LB79's Profile: http://www.e...

How to add days in date by macro
Hi all, I have TextBox1 on Sheet1 and in that TextBox1 I have date like "15/02/2010". I made macro (see below) in which I tried to get a date in cell A7 of Sheet2 which should be the date of 42 days ahead of the date in TextBox1. My macro is not working and I am getting error saying "Run-time error '13': Type mismatch". Please can any friend help that what i am doing wrong. Sub dd() tx = Sheets("Sheet1").TextBox1.Value With Sheets("Sheet2") ..Range("A7").Value = tx + 42 End With End Sub Try Sub dd() tx = Sheets...

files won't save
Can anybody help me. Some of my Excel files won't save. They just generate apparently useless error reports to MS in Win XP. I may have a macro virus but how can I turn off macros so that files open without running macros or so that the virus cannot run itself ? Best regards, Iain. Hi! Tough times. What are these *apparently useless error reports to MS in Win XP* that you are receiving? What sort of files is it affecting? All? Some? Do you have a virus checker? Have you used it? Tell us more: it could be useful. Al -- Message posted from http://www.ExcelForum.com ...

Bulk insert of chart titles?
I have several worksheets in a workbook, the layout on each worksheet is the same as the others, and each sheet has a chart, displaying charts of the data in each worksheet. I am able to insert chart titles into each chart, one at a time, but would like to do this as a single operation, in other words is there any way that I can insert a title in each chart referencing the same cell in each worksheet, in one operation? Stan - You need a little macro to do what you want. This loops through every worksheet in the active workbook, and for every chart on the worksheet, it adds a title t...

Forgot how to assign a macro to a button object
I created a macro, now I've forgotten how to assign it to a button object in the workbook. I tried right-clicking on the sizing handle, but the shortcut menu does not have "Assign Macro" on it. (The help system assumes it does and proceeds from there, leaving me behind.) Any suggestions? Thanks, Steve You used a commandbutton from the control toolbox toolbar. Delete that one and add the button from the Forms toolbar. Steve Conover wrote: > > I created a macro, now I've forgotten how to assign it to a button > object in the workbook. I tried right-clicking ...

How could insert symbols e.g. micro in chart legend in Excel?
when we make a chart in Excel and chart legends need to have some symbol character like micro molar, How could we create it, I tried but micro symbole chane to "m". Unfotunately I the only way I know is to put what you want in a text box and past oveer the lable text "farmash" wrote: > when we make a chart in Excel and chart legends need to have some symbol > character like micro molar, How could we create it, I tried but micro symbole > chane to "m". Micro (µ) can easily be typed by holding ALT down and typing 0181 on the numeric keypad. T...

Excel Macro #7
I need a macro that will take the infomation from one worksheet and replace it with information from another worksheet if there are any changes in 3 rows as long as all of the other information matches. Lita Details and before/after examples -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "Lita" <Lita@discussions.microsoft.com> wrote in message news:EF9AA5B7-B1F3-497F-A19E-03AD90D2CA7C@microsoft.com... >I need a macro that will take the infomation from one worksheet and replace > it with information from another worksheet if there ar...

can you link a pivot chart from excel to powerpoint
Can anyone tell me if you can link a pivot table chart from excel to powerpoint while keeping all the drop down functionality of the pivot chart or likewise I have some charts that I have attached control boxes to which help the user select the data they wish to see and the chart updates with whatever data selection they choose when I paste-special this into powerpoint even though its liked the functionality of the control box goes. I believe the answer is no, but have you tried using hyperlinks in Powerpoint to bring up the Excel graph itself during the presentation. it is easy to s...

Excel (2007) Chart Refuses to Accept More Data Points
I have a simple chart set up that references data points which are vertically ten spaces apart. The chart has worked fine for months. However, when I went to update it with another series point today it simply will not "OK" the extra point. I click enter, I click okay, and NOTHING. It's not just one chart that this is happening with, either. In the same file I have another chart that references another point that is spaced like the previous one but I have the same problem. I've never had this happen before and tooling around with it hasn't yielded any fruit. Some sa...

Excel Macros #15
I've created a macro on an existing worksheet and when I run it I get: Compile Error: Procedure to large. How do I combine this macro into two macros without the hours I spent originally? Cut out logical pieces of the code and make them sub procedures and then call the sub procedures in your main code. (Insert Procedure) "TKO II" wrote: > I've created a macro on an existing worksheet and when I run it I get: > Compile Error: Procedure to large. How do I combine this macro into two > macros without the hours I spent originally? ...

Filter Macro when Criteria Changes Daily.
I am using Excel 2007 and I need to set up a macro/code to filter items, copy them to a new worksheet and save them as the filtered name with date. This needs to be run everyday but the items that need to be filtered can change each day. Sometimes they will be there and sometimes they won't. I=92m having issues with the code for the filtering. Any help will be appreciated. On Oct 25, 9:57=A0am, Sam <samcan...@gmail.com> wrote: > I am using Excel 2007 and I need to set up a macro/code to filter > items, copy them to a new worksheet and save them as the filtered name > w...

Chart Goal Lines
How do I add a goal line on my charts using Office 2007? HTH: http://peltiertech.com/Excel/Charts/AddLineHorzSeries.html Micky "Office User" wrote: > How do I add a goal line on my charts using Office 2007? ...