ActiveX Listbox Does Not Work With VBA Code For Changing Chart Axis Scale?
Jun 5, 2014
I have some code for changing the scale of my chart axes so that when new data is inserted into the column which the chart sources from (say column B), the axis scales on my chart will automatically adjust (as the Excel algorithm sometimes leads to charts which are a bit squashed). This code works fine, and I have included it below.
I have then tried to introduce an ActiveX listbox so that when you select an item in the box, the reference number generated (1,2,3...etc) then determines which data series is inserted into column B using a vlookup function. However, when I do this, the original VBA code for automatically adjusting the chart axes no longer works.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveSheet.ChartObjects(1).Chart
how to get the min value scale value off a graph when .MinimumScaleIsAuto = True? The reason I ask is that I want to make my baseline for the graph that min number so that names from the x axis are not sitting in the middle of the graph. Incognito Auto Merged Post;I feel real bright...just playing around I found my answer...
I want to automate the Display labels in my Charts using VBA Coding…
I would need to use this small code in Charts with different Scales as some of the Scales in my Data are in a very large Range close to Trillions so its not possible to have these as the Primary-Y-Axis Scale and therefore I would need to use the in-built Display label option which Excel provides..
However, I always prefer to have the scale in the Range of Thousands so the Max I can have in the Scale can be 10,000 so if there is any Number more than that or the Scale is going above than I would prefer that this gets auto-calculated to Multiply with the remainder and show appropriate Scaling.
For Ex:In this example My largest Number is 4500000000 which is 100 M..So I would want the scale to show 4500 and the Display label as X Millions..
So The Display Label would be different for different Ranges but the Max Scale preffered would be 10,000.
1) How do make values on x-axis as words? E.g. apples, oranges, etc.
2) Is it possible to have the numbers on x-axis in descending order? If I can figure out 1), I can do this as well, but it would be nice to know if it is possible to have the numbers on x-axis in descending order.
The scale on our chart in the X axis is mandating a numeric number. It is showing "39200" instead of 4/28/07. In any event, we would like to have 4/9/07 -- the last date we have data for and the last date that we have referenced on the X axis.
The chart is in the attached chart.xls and the data is in the attached chart.xls
Basically I have some performance figures for a fund that I want to make a chart for, the problem is that the first date (the start date of the fund) is 15/09/2011 but every reporting date after that is the end of the month.
So my data looks something like this (not real figures)
So what I want is a graph where the x axis starts at 15/09/11 but then the next label is 30/09/11 and 31/10/11 etc, while still keeping the scale proportionate to the dates, ie the distance between 15/09/11 and 30/09/11 will be half the distance between 30/09/11 and 31/10/11.
The 2 outcomes I seem to be stuck with is either forcing the graph to start at 31/08/11 and making the y axis cross at 15/09/11, however with this the x axis goes left past the y axis cross point and it just looks dumb, although everything right of the y axis is correct.
Or secondly I get the graph to start at 15/09/11 and set it to label every 1 month and all the labels are 15/09/11, 15/10/11, 15/11/11 etc
Graph No. 1 with smaller time frame, Daily. Graph No. 2 with larger time frame, Weekly. Objective: Add vertical line to mark the same times in both graphs.
Trouble is both graph already utilise the secondary axis. VBA is allowed.
I have a spreadsheet with golfers handicaps, golfers names down the left in column A in rows 3-35. Row 2 has the event numbers titles 1 to 18 (18 events in a year). i need a graph that has the person as the vert axis and the horizontal axis needs to be the event numbers, so i can read down for the person and across to see how there handicaps change from each different event. i have attached the data below.
I have some numeric data that has to be put on a log chart. but there is no option for log charts. so i converted my data to log and then drew a chart but i am unable to edit the axis intervals and starting axis value. whenever i change the value it gets back to its default value,ie 1. can anyone tell me how to draw log chart or how to edit axis intervals and starting axis value?
how to incorporate another category and value axis to my existing chart.
1. I need to add a rank axis derived from my data column (C6-C15). This column should rank from highest to lowest and create a tie if any number is repeated. I have arranged the rank column in cells B38:L38 as they would appear. I would like this to appear on the top or bottom of the bar graphs.
2. Second I need to add the frequency of hits which = 3 derived from cell J1 This should appear on the chart were it is currently titled. This should create another bar graph colored green and labeled 3.
3. Lastly the numbers axis can remain the same as it appears on the chart or if it would be better to align as shown in cells B43:L43.
I have two listboxes on a worksheet and using VBA to load values into the listbox. I also have a combobox that is used to determine what values are to be displayed in the listboxes. I select a value from the dropdown list and depending on the value selected, a list gets populated in the listbox. This works just fine.
The problem I'm having is that when I adjust the zoom on the worksheet, 75% for example, the listbox automatically changes the width when new values are displayed. I try using the listbox1.width = xxx, to keep the width in place, but that doesn't really work.
I am using a VBA macro which performs a Yahoo webquery to obtain stock data. After the data are downloaded, a chart is updated with the new data.
The current macro updates the scaling on the price axis just fine, however, if I change the time frame the x axis, i.e, time/date axis is either spread out to far or jammed up.
The code for re-scaling the the y axis is shown below:
Code: Sub UpdateScale() Dim ChartVar As Chart Dim lMax As Long, lMin As Long On Error GoTo ScalingProblem 'Assigns the values in the Min and Max ranges to variables.
[Code]....
Any similar sub that would also rescale the x axis as needed when the data intervals are changed?
I have a Scatter chart that plots a simple XYScatter plot. The data for this plot can be very wide ranging, and for that reason, I use AutoScaling to scale the axes. Nine times out of ten, it works just fine, but it seems that when the X data ranges from about 5200 to 7200 +/-, the autoscaling does not calculate well (example attached).
Autoscale range will go from 0 to 8000, leaving a large area of unplotted graph space.
I thought the original issue was that I may be plotting zeros or blanks, but I've eliminated that problem. I have yet to find another range of values that causes it, but I'm sure there's some. What is it about the way that Excel calculates its AutoScaling that I'm missing?
What do you all recommend to eliminate this problem? Manually scaling it is not really an option in this case, as I want this to be completely transparent to the user for ANY range of data.
How can I add missing values to the axis in a pivot chart line chart? I have a numerical X-axis with values such as 0,1,5,8,14, etc. I have another set of Y values that correspond to the X values. If this was an XY-scatter plot I'd be able to plot X vs. Y and connect the dots for "gaps" in the X values. Since it's a pivot chart I cannot use an XY-scatter plot, I can only use a line chart. The line chart doesn't give me the ability to add the "missing" values, so it gives the impression that my data is more closely packed than it is. The data source is external to my spreadsheet, so I cannot add the values before creating the pivot table/chart.
I am using Jon Peltier's worksheet_change event code to try and automate chart axes.
Private Sub Worksheet_Change(ByVal Target As Range) Select Case Target.Address Case "$AG$5" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _ .MaximumScale = Target.Value Case "$B$3" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _ .MinimumScale = Target.Value Case "$AG$7" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlCategory) _ .MajorUnit = Target.Value Case "$L$3" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _ .MaximumScale = Target.Value Case "$N$3" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _ .MinimumScale = Target.Value Case "$AH$7" ActiveSheet.ChartObjects("Chart 2").Chart.Axes(xlValue) _ .MajorUnit = Target.Value Case Else End Select End Sub
However, I have some of the cells setup as formulas....but worksheet_change apparently only updates values when manually changed.
I got a set of data which is only 2 colums collecting data problems. The output i get is a time stamp and a fault. Im looking to set a chart up with the time been on the X - axis and number of problems per hour on the Y - axis.
is there a way of changing the text direction for an ActiveX textbox? I need it to show the text in some of the boxes vertically but in other boxes horizontal.
I am trying to manually format a few graphs in my sheet. I, however, leave the major units of the axes to be automatically calculated. The code that I use is given below:
ActiveChart.Axes(xlValue).Select With ActiveChart.Axes(xlValue) .MinimumScale = Range("Min").Value .MaximumScale = Range("Max").Value End With
Now what this does is that it sets the maximum of the scale exactly equal to maximum of the range being plotted and hence a few parts of my graph overlap with the border of the plot area. Is there any way in which I can round the max and min scale of y-axis to the next highest and lowest major unit respectively or may be add and subtract a value proportional to the major unit of the y-axis. I cannot add a constant in the code given above since I that does not suite my requirements.
I have modified the Run as Regular Macro code from this site to only changing the x axis, select different cells and I also only used object 1 instead of the name of the chart.
The problem is that when it is run which ever value is changed last, minimum or maximum, it will turn on auto and mess it all up.
I have some simple data and i want to create a horisizontal bar chart with 2 axis (X axis) the top one showing number of stocks number up to 270 and the bottom with Market Cap up to 1,200. (See attached). I set up the chart and it looks fine but it has only one axis so in order to create a second axis i right click on the blue series (no of Stocks) and go through the motions of setting up a secondary axis. However when i do that it ends up looking like the chart to the right with the Bars Cojoined (which is not what i want) I cannot seem to achieve 2 axis with separated bars
How can I change the typeface to Times New Roman for all three and change the font size for the Axis titles? hundreds of charts to change and not enough patience to to it manually.
I'm trying to change the default option for the data series when graphing in Excel 2003 .... I am trying to create a line graph
Excel, by default, is putting static pressure on the x axis and the air flow on the y axis .... I need it to be the other way around
I have found out that: By default, Excel plots whatever you have fewer of—rows or columns—as the data series
apparently it is possible to change this Excel default option, but I can't figure that out
in step 2 of the Chart Wizard, I have tried many different things, but can't get Excel to chart the Air Flow CFM on the x axis, and have static pressure values on the y axis
How to autoscale chart using VBA, so i can maximize the viewable area without using the default format axis on chart each time i paste new data to the table,
I have a simple piece of code that creates a chart using the the values in column A as the x-axis and the values in column E as the y-axis. The values in Column A are all dates in this format: mm.dd.yyyy. However, when I collect the x-values they always appear as numbers (1,2,3). Even if I format the axis to Dates, they appear as 1.00.1900, 1.02.1901, etc.
Here is the code (also, I would like a VBA solution but if this is with excel's chart tools, so be it).
Code:
Sub Macro2() ActiveSheet.Shapes.addChart.Select ActiveChart.ChartType = xlXYScatter ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).Name = "=""Rate of Productivity""" ActiveChart.SeriesCollection(1).XValues = "='Sheet1'!$A$2:$A$4" ActiveChart.SeriesCollection(1).Values = "='Sheet1'!$E$2:$E$4" End Sub