Update Chart X Scale With VBA
Feb 16, 2012
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?
View 6 Replies
ADVERTISEMENT
Sep 26, 2007
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.
View 9 Replies
View Related
Dec 14, 2007
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...
With .Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScaleIsAuto = True
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = .MinimumScale
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
View 2 Replies
View Related
Dec 10, 2008
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.
View 9 Replies
View Related
May 15, 2008
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.
View 2 Replies
View Related
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
[Code].....
View 4 Replies
View Related
May 16, 2013
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.
View 8 Replies
View Related
Feb 1, 2013
How can we convert time on a scale of 100 to a scale of 60?
View 3 Replies
View Related
Feb 21, 2014
I had a couple of days ago..
I can get the "Daily %" to update just fine but for the life of me cannot get the "Total Number of Patients" to update.
View 3 Replies
View Related
Feb 11, 2009
I'm trying to make a scatterplot so what I did was recorded a macro and now I want to be able to update it using a for-loop. Here's my code.
View 4 Replies
View Related
Dec 14, 2012
I am making a macro to update the data on a bunch of charts. This is what I got from the macro recorder when I selected the data manually.
Code:
Sub testthree()
ActiveWorkbook.Charts("Julian's Words").Select
ActiveChart.SetSourceData Source:=Sheets("Super Sight Chart Data").Range( _
"C1:H1,C5:H5"), PlotBy:=xlRows
End Sub
I have created the part of the macro that will go to the data table and define the two ranges I need to use.
Code:
Sub Adjust_Graphs()
Dim lastdate As String
Dim daterange As Range
[Code] .....
However, this code is selecting the entire range C1:H5. How can I get the code to take JUST the two lines I need?
Exmaple: The X axis needs to be C1:H1, and the Y axis needs to be C5:H5.
I also tried this, without success:
Code:
Dim combrange As Range
Set combrange = Union(daterange, wordrange)
ActiveWorkbook.Charts("Julian's Words").SetSourceData Source:=Sheets("Super Sight Chart Data").Range( _
combrange), PlotBy:=xlRows
View 1 Replies
View Related
Aug 30, 2007
I'm trying to change the source data for a worksheet for a series of charts. The source data appears in a series of tables. There are about 30 such tables and associated charts on the worksheet. (I need to duplicate this many times over, which is why I need to automate.). The chart names seem to increment by 2 (i.e. Chart 1, Chart 3, Chart 5) And the source data for the charts increment by 9: BM95:BP102, BM104:BP111, etc. How can I automate this? Also, I'm trying to automate changing the reference in the title of the chart. This reference increments rows by 9. When I use the macro recorder to do this, I get the following
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Range("BM95:BP102")
I'm unable to generate any code that allows me to change the reference of the chart title.
View 4 Replies
View Related
Mar 17, 2008
I have a macro that extracts data from a source workbook. The data is owerwritten every time that I use the macro. Now I have a graph that everytime I use the macro does not update with the new data, Is there a clever way to do that? The code for extracting from the workbook is the following:
Sub Extract()
Dim myFileName As Variant
Dim SourceWkbk As Workbook
Dim CurrentWkbk As Workbook
Dim testWks As Worksheet
ActiveWorkbook.Sheets("CURRENCIES").Select
ActiveWindow.SelectedSheets.Delete
myFileName = Application. GetOpenFilename("Excel files,*.xls")
If myFileName = False Then
Exit Sub 'user hit cancel
End If................
View 4 Replies
View Related
Apr 12, 2006
I've been updating all the charts manually each time I update the entries in the worksheet which charts are created from in the same workbook. Is there any way (eg. by use of macros or VBA) that I can have all the charts updated automatically when data ranges are updated each time?
View 2 Replies
View Related
Aug 19, 2006
I have attached a copy of the chart and data. My chart starts on the bottom. I had to take out a lot of data but beneath the data shown is much more data..
I want my chart to automatically update when new data is added. Here are the issues. I have several lines of headers and below that my data. Then below my data I have other data that I don't want displayed in the chart (its not shown here because of size limitation of attachmnet).
The new row will be added each time right below the header, right above the
most recent data given. So a row will be added above row 8!
View 9 Replies
View Related
Aug 31, 2007
I'm trying to create a chart and set its source dynamically.
I've tried two methods, the first by setting the XValues of a chart's series collection to a range specified by cells,
ActiveChart.SeriesCollection(1).XValues = range(Cells(9, coloffset + 4), _
Cells(9 + numvsteps, coloffset + 4))
And by using the chart wizard.
Call vchart.Chart.ChartWizard( _
Sheets(resultssheet).range(Cells(9, coloffset + 6), Cells(9 + numvsteps, coloffset + 6)), _
xlLine, , xlColumns, _
Sheets(resultssheet).range(Cells(9, coloffset + 1), Cells(9 + numvsteps, coloffset + 1)), , _
False, "End-End Eff., " & current & "A", "Line Voltage", "Eff. [%]", "test")
Setting the XValues property gives an "Unable to set the XValues property of a series class".
Using the chart wizard, trying to set the category labels parameter of the chart wizard to a range doesn't give an error message, but does leave the category labels section of the chart (when I click and view it) blank.
I've also tried
resultssheet = "Sheet1"
tempstring = "='" & resultssheet & "'!" & "R9C" & (coloffset + 1) & ":R" & (9 + numvsteps) & "C" & (coloffset + 1)
ActiveChart.SeriesCollection(1).XValues = tempstring
When I step through the code, tempstring is "='LineReg Results'!R9C1:R19C1", which is correct, but I still get an "unable to set the xvalues property of a series class" error.
Interestingly, if I record a macro of me setting the category labels, and play it back, I also get the error.
View 7 Replies
View Related
Jul 18, 2014
I want have a chart that use Formula result to update automatically. I know there is some vb methods to do this but my job is different and that ways work when values enter manually but i need a way that use formula result to update and don't make chart as long as existing values. I attached a sample of i need and i did explanation on it. The Salesman's are enter to column A by a VB and Their values of cost or earning are enter by a formula.
View 2 Replies
View Related
Mar 2, 2014
I have two charts (Chart A and B) and 1 duplicate chart of chart A ("Chart A", didnt change the change name so remain the same).
"Chart A" is overlay above Chart B to see the actual different.
When the data is updated, interval-Y in "Chart A" is different (by +-10% offset) than Chart A which support to be the same.
At this stage, comparison is not possible.
The interval-Y is link to vb.
Checked when there is offset the maximum and minimum offset is different and else I cant find any other problem.
Do I have to state that there are two Chart A in the vb?
View 1 Replies
View Related
May 2, 2008
I am having difficulty figuring out how to get my chart title to automatically update when my chart changes via filtered criteria. I can get it to change by clicking the title bar on the chart, but would like the title to automatically update as soon as I select new criteria and the chart changes.
View 9 Replies
View Related
Apr 12, 2007
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
View 9 Replies
View Related
Jun 18, 2014
A set low number of 100 is in cell B4, and a related set high percent of 18% is in cell B6.
A set high number of 1,000 is in cell D4, and a related set low percent of 14% is in cell D6.
In cell B8 a manual number will be typed between 100 and 1,000.
In cell B10 we want a formula that will roundup a percentage number between 14% and 18% depending on the number inserted in B8.
View 7 Replies
View Related
Jul 23, 2014
I am trying to create a scale using IF functions in Excel.
I have a row of numbers that I want to convert to my scale. My scale is fairly simple, less than 1 =1 and more than 10 = 1
After that, any number between 1-2 gets a 10, any number between 2-3 gets a 9, any number between 3-4 gets a 8, etc.
So, what I have done is take a logic if-then function and applied it to my row of numbers. It looks something like this:
=IF(2<D2<3,9)
However, this doesn't work. I have a number (2.55), and instead of showing a 9, it says FALSE. I am pretty sure 2.55 falls between 2 and 3 on the scale. Why won't it work?
Also, is there any way to create a function where I could put each of my if/then functions to create my whole scale? Right now I just have 10 separate columns for each number on my scale.
View 1 Replies
View Related
May 9, 2014
Here's the scenario. A co-worker and I access the same file from the same online database and download it in the same manner. We have the same version of excel. We then open these identical files, we run a formatting macro (identical), but when it comes time to set the page breaks in order to get the items to print on the same page I have to increase a columns width to make it fit on one page and yet it still doesn't match theirs. It appears to have a different scale but I'm not sure of the option difference between our machines. I don't know how it could be the printer since it physically gives her different page break option than what mine does.
View 1 Replies
View Related
May 1, 2014
I would like to scale an image to 124% how do I do that
View 1 Replies
View Related
Feb 14, 2014
My display scale is 125%. A college's is set to %100. This causes errors when I place Shapes to saved locations, .Top & .Left programmatically. Based on Google searches, it appears that setting the auto scale mode to DPI may solve this problem. How do I set it?
View 5 Replies
View Related
Jan 26, 2009
I have a list of items that each one has starting price, demands and current price. Current price changes by demands according to pre determined scale. Demands values are entered manually by user. I’m looking for a formula that will calculate current price automatically according to the scale & demands. I cannot know what will be the amount of demands (it could be 0 or 5000...) but I do know that demands are sequential integer numbers, positive or negative. I also don’t want it to exceed the minimum and maximum value that determine by user. I think the attached file will explain well than what I’m writing.
View 5 Replies
View Related
Oct 3, 2008
I AM TRYING TO WRITE A FORMULAE BASED ON THE FOLLOWING SLIDING SCALE.
0 - 49.99 = 9.9%
50 - 599.99 = FIRST 50 @ 9.9% (4.95) THEN AT 5.8%
600 ABOVE = FIRST 50 @ 9.9% (4.95) + 50 - 599.99@5.8 (32.45) AND THEN 600 ABOVE AT 1.9%
this is what i came up with, but it is not excepting the formulae.
=IF((C4
View 9 Replies
View Related
Oct 14, 2008
My question is that i have to scale my data.. Can i do Z-transformation..
Is there any inbuilt function or shall i have to write Code,
View 9 Replies
View Related
Nov 19, 2006
Calculate the intensives to be paid to a loan officer based on the number of cases he brings , according to the following :
the first 10 cases 0
from 11 to 15 cases 6 pounds
from 16 to 20 cases 8 pounds
from 21 cases to more 10 pounds
so I need to put the total number of the cases , the loan officer brought in one cell, and this value to be processed and splitted to the segments above , and multiplied with adjacent pounds sums , and finally calculate the total of theintensive to be paid.
View 9 Replies
View Related
Dec 7, 2006
I have a big set of data, where I requires to zoom in to view the details of the graph (by scaling the X and Y axis). I am thinking of a graph that can use 4 scroll bar to control the zooming. 2 for each axis, where one control the difference between the maximum and minmum value (Zooming effect, minimum value always the same), and one to scroll the range of the data without zooming, (maximum - minimum) always the same.
View 5 Replies
View Related