I haven't had to use Excel graphs for more than 10 years... and find myself needing to create a simple chart with a series of lines.
Each line will start at (0,0), and then move to the (x,y) points specified.
For example
X,Y
20,5000
25,7500
40,9000
This should have three lines. All of them start at (0,0), and move to the points specified. Ideally, I'd like to be able to specify the max ranges, and have the lines start from (0,0) and keep going until they hit the boundaries.
This should be really simple to do, but I can't recall how, and all my Google search results are assuming I want to do something far more complex.
Any help?
Thanks
You will need to do a bit more processing on your data to get the result you want but I believe it is doable fairly simply
First, identify your maximum X value (in my example I have chosen 20000 (cell (A2))
Then list out the X and Y values for the Series, with their origins (0,0) and their values as listed in your table above (Cells A4 through F5)
You can then copy the maximum value into Row 6 in cells A6, C6, E6 to make the next bit easier to understand.
Then you can use the TREND function to extrapolate from your known data (rows 4, 5) up to your maximum value (row 6)
For Series 1 for example the expression
(Cell B6) =TREND(B$4:B$5, A$4:A$5, A$6, FALSE)
Says, for Y-values B4 and B5, I know the corresponding X-values A4 and A5, so if I also have A6 as the maximum X-value, what would the Y value be? (the False just says the equation must go through the origin)
You now have a table that looks like this
Create a new “Scatter With Straight Lines and Markers” chart and add three data series. Series1 would look like this
Once all three series have been added you now have a chart that shows the lines up to your maximum value for the ratios you have defined above.
Hopefully this is helpful. Let me know if I can be of further assistance.
Related
I have an Excel Sheet that I need to conditionally format so I can tell how close numbers in the cells are to the midpoint of a range. These are the rules:
Blanks = WHITE
Values outside of my desired range (Rows B and C) = RED
Values inside of my desired range will scale with the midpoint = GREEN and the outer points = YELLOW
Format Rules
If I make a separate condition on every row, it is CORRECT and looks like this:
Correct
But that would take an insane amount of time to create rules for every row.
If I make the following formula to try to speed things up, it calculates correctly for the first row and then incorrectly for the remaining rows (only using the numbers from the first row).
3-Color Scale Example:
Minimum =INDIRECT("B"&RIGHT(ADDRESS(ROW(),COLUMN(),4,1),LEN(ROW())))
Midpoint =(INDIRECT("B"&RIGHT(ADDRESS(ROW(),COLUMN(),4,1),LEN(ROW())))+INDIRECT("C"&RIGHT(ADDRESS(ROW(),COLUMN(),4,1),LEN(ROW()))))/2
Maximum =INDIRECT("C"&RIGHT(ADDRESS(ROW(),COLUMN(),4,1),LEN(ROW())))
Incorrect:
Color scales don't accept relative references in the value formulas. You'll have to bite the bullet and use absolute references and adjust the row number for each row.
So in our experiment we took several samples from a number of fields. In each of these areas we counted the number of clover plants and their sizes. So each row of the table is one sample with how many size1, size2 (etc) plants appeared in that sample. So I want to know whether there is a code that I can put into column G that will work out what the median size class is.
For example, Column G would show 'size1' for Row 7, because it is the middle value if the data were lined up (size1, size1, size1, size2,size4).
Again I'm sorry if I'm making a total pig's ear of this. Stats seems to be very good at stumping me at the simplest things.
If you're trying to return the column header from the column that has a non-zero number, you can use this in G2, and drag down:
=INDEX($B$1:$F$1,SUMPRODUCT(MAX(($B2:$F2<>0)*(COLUMN($B2:$F2))))-COLUMN($B$1)+1)
Note you can wrap that in IFERROR([formula], "") to hide the error that occurs if there's not a cell that's not equal to 0.
I have 3 columns with percentages.
I would like to put an up or down arrow in the same cell as each percentage depending on the previous percentage.
ex: H10 = 54, L10 = 55, P10 = 50
I'd like L10 to read 55 with an up arrow and P10 to read 50 with a down arrow. Then I want to copy this formula down to the 500th rows for columns L and P.
I was able to create this for 1 row (H10, L10 and P10), but when I tried to copy it down to the other rows, it continued to reference the first row (H10, L10 and P10), . I tried to remove the "$" absolute reference and got an error message saying I cannot use relative references. How can I copy this formatting all the way down.
The fields I am using (row H, row L, row P):
Here's what I did to get around this:
I added another cell and calculated the difference between the rows, then set the formula to evaluate if the difference was negative or positive (greater than or less than 0), if it was positive there is an up arrow and if negative there is a down arrow. I made the new row small enough that only the arrow shows and the number doesn't, and I don't have borders on the two rows (the one with the number and the one with the formula) so it looks like the additional row is actually part of the row that has the true value (not the calculation).
There is one way I can think of to get a relative reference while only using what "looks like" an absolute reference.
= $A1
returns the same thing as:
= OFFSET($A$1,ROW()-ROW($A$1),0)
Notice that the formula above uses only absolute references but effectively returns a relative reference.
Try using this method to see if it will work in your case.
As seen in the picture I have 5 sets of 2's in one column.
I would like it so that each set is in its own column.
Is there a way to do that?
I tried text to columns, but it did not work.
General solution
Imagine I have a vertical array starting in cell B2, which I want to separate into N stacked columns. I will place these columns from cell E4, as the picture indicates.
The code which achieves what I want is:
+OFFSET($B$2,(ROW()-ROW($E$4))*N+(COLUMN()-COLUMN($E$4)),0)
Replace N with your desired number (and the origin and destination cell with your particular values, B2 and E4 in this example), and expand the formula vertically and horizontally to form your desired matrix of N columns. For the case of N=3, you get:
(PS: if your array is horizontal, use transpose to transform to vertical. You can then transpose the resulting matrix, to get the final result.)
Explanation
The logic is simple. The function OFFSET has three compulsory inputs. The first one is the first point of your array you want to transform (in the example above, $B$2. The point you select has an index of 0, the one below an index of 1, etc. So, what you want is to put these ordered index into a matrix form, as shown below (for the case of N=3):
The rule to move these indexes is given in the second entry of the OFFSET function. This is basically a formula that calculates a sequence 0, 1, 2, 3 ... using some fixed values (the number of the row and columns of the first cell where you are putting the result, ROW($E$4) and COLUMN($E$4), which are equal to 4 and 5 respectively), and the variable values of the cell where you are placing the number (ROW() and COLUMN()). The formula computes the difference between actual row and reference row number, scale it by N, and adds any difference between actual and reference column. This formula gives the desired series 0, 1, 2, 3... for our desired output matrix.
Finally, the last item of OFFSET is equal to zero, since we are transforming with a vertical column of data, so no horizontal offset is needed.
You can do it with e.g. formula; enter this to C1 and fill down and right:
=OFFSET($A$1,ROW()-1+(COLUMN()-3)*6,0)
Take the total cells, dived it by 3 and cut and paste. I wasted a 30 mins trying all the solutions offered out there.
I gave up and now my project is complete. Only took about 15 seconds.
To split one column into multiple columns with column first order, in other words, without transpose, we can modify the formula as shown in https://www.extendoffice.com/documents/excel/3132-excel-convert-vector-to-matrix.html, which is the solution for row first order, i.e., with transpose, exchange the roles of ROW() and COLUMN(), example code:
=OFFSET($A$1:$A$10494,ROW()-ROW($B$1)+((COLUMN()-COLUMN($B$1))*(ROWS($A$1:$A$10494)/18)),0,1,1)
Here $a1:$a$10494 is source, $b$1 is destination, 18 is columns numbers to split into.
This can be used to get back the table structure of %debug print output in pdb, for example, which will split the output into narrow bands.
I have this chart in which if any point in graphs exceeds specific limit then its color should change.
can anyone suggest me how to get the chart in VBA and then apply this kind of condition e.g i want to change the color of highest point in the above graph . Any help would be highly appreciated.
Using: ActiveWorkbook.Sheets("Sheet1").ChartObjects("Chart1").Chart.SeriesCollection(1)
Color of each point is .Points(PointNumber).Interior.Color
The number of points you have to cycle though is .Points.Count
The value of each point is .Points(PointNumber).Value
colors of the markers themselves (Applies only to line, scatter, and radar charts):
.Points(PointNumber).MarkerBackgroundColor = RGB(0,255,0) ' green
.Points(PointNumber).MarkerForegroundColor = RGB(255,0,0) ' red
.Points(PointNumber).MarkerStyle = xlMarkerStyleCircle ' change the shape
Let's take another approach, which does not require any code.
Assume your data is in columns A (sequence number or time) and B value, starting in A2 and B2, since your labels are in A1 and B1. We'll add a series to the chart that includes any deviant values from column B. This series will draw a marker in front of any deviant points so the original point will still be present, and instead of reformatting this point the new series displays a point.
In cell C1, enter "Deviant".
In Cell C2, enter a formula that detects a deviant point, something like:
=IF(AND(B2>upperlimit,B2
This puts the value into column C if column B exceeds upper and lower limits, otherwise it puts #N/A into column C, #N/A will not result in a plotted point.
Copy the data in column C, select the chart, and Paste Special as a new series. Format this series to have no line and whatever glaring marker you want to use to indicate an out of control point.