Excel spreadsheed populate cell based on value of another cell - excel

I have a excel spreadsheet that contains a bunch of columns. My first column contains values of mpg(about 300 entries of miles per gallon). What I want to do is populate another column
based on whether the value of the first cell is greater than or less than 23.5
So basically it looks like this:
**A** **B**
10
15
29
14
32
24
I want column B to be populated depending on if the corresponding cell (eg. A1 > 24.5 so populate B with yes) is greater than 24.5 with yes or no.
Is there a simple function I can use to do it on all the values?
Please do provide detailed instructions since I hardly use excel and I'm lost on this past.

Type =IF(A2 > 23.5,"yes","no") into B2. Then double-click the bottom-right corner of the cell (the little box) to fill the rest of the cells.

Related

How to fill cells dynamically based on the value of a cell? How to segregate values based on a particular cell?

Suppose, I have secured Marks for a particular subject which have 5 course Outcomes (each containing 2Marks--Total 10 marks for each subject).
I have the total marks obtained for all the students, but not the marks of each CO.
I want to fill the COs(Column B-F) based on the Column H(Total).
Example- A Student having total of 8 should have the value- 2,2,2,1,1 or 2,2,1,2,1, etc
Conditions-
All the cells should be filled in case of marks with >5
Each cell should have the value between 1 and 2. 0 in case when total is less than 5. As we don't have enough values to fill:
Previously, I used the randbetween(1,2) in Columns B to E (to get random values between 1 and 2) and for Column F, I used the formula =10-SUM(B6:E6)
It works fine, but doesn't work well if the difference is more than 2(which violates our condition)
With 2007 we need to refer to the cell in column A, so change that to an empty cell or text. Put this in B2 and copy over and down:
=IF(SUM($A2:A2)+6-COLUMN(A$1)>=$H2,1,IF($H2/(6-COLUMN(A$1))>=2,2,RANDBETWEEN(1,2)))
with Office 365 we do not need Column A to be blank or text as we no longer need to refer to it:
=LET(
sm,H2,
rng,B2:F2,
clm,COLUMN(rng),
{1,1,1,1,1}+ISNUMBER(MATCH(clm,TAKE(UNIQUE(RANDARRAY(1,100,MIN(clm),MAX(clm),TRUE),TRUE),,sm-5),0)))

How to create a dynamic formula to find the average of a set of values for a given vector

I am trying to create a formula that gives me the average of the last 12 entries in a given dataset depending on the associated vector.
Let's make an example:
I have in column F2,G2,H2 and I2 dates, Company1, Company2 and Company3 respectively. Then from row3 to row 33 I have months dates starting from May 2016.
Date Company1 Company2 Company3
May-16 2,453,845
Jun-16 13,099,823
Jul-16 14,159,037
Aug-16 38,589,050 8,866,101
Sep-16 63,290,285 13,242,522
Oct-16 94,005,364 14,841,793
Nov-16 123,774,792 7,903,600 41,489,883
Dec-16 93,355,037 12,449,604 69,117,105
Jan-17 47,869,982 13,830,712 83,913,764
Feb-17 77,109,905 10,361,555 68,176,643
The goal is to create a formula that, when I drag it down, correctly calculates the average of the last 12 values for a given company.
So for example i would have, say in table "B2:C5":
Company1 76,856,345
Company2 11,120,859
Company3 65,674,349
And, if a new Company4 is added to the list, then I just have to drag it down the formula, to calculate the average of the last 12 months for Company4.
Until now, I have came up with this formula:
=AVERAGE(LOOKUP(LARGE(IF(ISNUMBER(G:G),ROW(G:G)),ROW(INDIRECT("1:"&MIN(12,COUNT(G:G))))),ROW(G:G),G:G ))
This formula correctly calculates the average of a given column, considering only the last 12 values. The last step would be to come up with a formula that includes all the columns and then calculates the average for the given company.
Thanks!
I recommend that you use a named range to define your data in columns G:I. When a company is added, just modify the named range's specs. I used the name Target. Of course, you can replace it with $G:$I if you feel so inclined but I would rather recommend reducing the number of rows in the range, which is easier to manage when it is named.
Use the formula below to extract the company names from the first row of Target into the first column of your averages table. This is to ensure that the names are spelled identically in both locations.
=INDEX(Target,1,ROW()-2)
The number 2 indicates the number of rows above the row containing the formula. it is copied here from cell M3. There, ROW()-2 creates the number 1, counting sequentially as the formula is copied down.
Now I have the formula below in my cell N3 and copied down.
=SUM(INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0)))
The formula simply sums up the columns G, H, and I in 3 consecutive rows.
In the final step I inserted the range definition established above, meaning excluding the SUM() function, into your existing formula.
=AVERAGE(LOOKUP(LARGE(IF(ISNUMBER(INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0))),ROW(INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0)))),ROW(INDIRECT("1:"&MIN(12,COUNT(INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0))))))),ROW(INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0))),INDEX(Target,0,MATCH($M3,INDEX(Target,1,0),0))))

Excel (Google Spreadsheet): get values between two dates

I have seen lots of questions regarding this, on here and on other websites. However even with all that I have read I cannot accomplish what I want.
I have an Excel document with in cell A2 a starting date and in B2 an end date.
In A5:C11 I have a table with data. In cells A5:A11 I have dates, in B5:C11 I have the data. Now I want to display the data from B and C if they fall between the dates given in cells A2 and B2. I want to do so via a formula. I have tried many formulas with index, match, vlookup, small , sumproduct, if(s) and so on. Maybe any of you can help me?
Start date End date
29-12-2017 29-12-2017
Date Users Pageviews
04-01-2018 350 400
03-01-2018 300 350
02-01-2018 250 300
01-01-2018 200 250
31-12-2017 150 200
30-12-2017 100 150
29-12-2017 50 100
In this case I want the output to be, preferably in 3 cells:
29-12-2017 50 100
Make another table in F5:G11 with this formula in F5 and copy over:
=IF(AND($A5>=$A$2,$A5<=$B$2),B5,"")
Then in H5:I11 use this formula to remove the blank rows (adapted from here):
=IFERROR(INDEX(F$5:F$11,AGGREGATE(15,6,(ROW(F$5:F$11)-ROW(F$5)+1)/(F$5:F$11<>""),ROWS(G$5:G5))),"")
The result:
Parameter to change in green, your data in blue, intermediate formulae in grey (hide these columns?) and the final result in orange.
To get the list of dates use:
=IFERROR(AGGREGATE(15,6,$A$5:$A$11/(($A$5:$A$11>=$A$2)*($A$5:$A$11<=$B$2)),ROW(1:1)),"")
Then once we have the dates it is a simple Vlookup for the other two:
=IF(F5<>"",VLOOKUP($F5,$A$4:$C$11,COLUMN(B:B),FALSE),"")
Put the First in F5 and copy down.
Put the Second in G5 and copy over one column and down.

How To Write Series Of Number In Excel

I want to write numbers in excel starting from 000001 till 999999
I have done like this =TEXT(A2,"000001") but i am not been able to generate series even though not able to separate this in different attributes
Further I want to distribute each number in each different cell for example like this
A B C D E F G
000001 0 0 0 0 0 1
000002 0 0 0 0 0 2
till
999999 9 9 9 9 9 9
Use following formuls to B1 cell and drag then right and down as needed.
=MID($A1,COLUMNS($A$1:A$1),1)
See the screenshot.
Here is a better way:
In cell A1, type 1.
Select A1 and from Home tab, choose Fill > Series (top-right).
Choose Columns; Linear; set Step Value to 1 and Stop Value to 999999 or whatever you want. Click OK.
Use AutoFill feature to fill up to the number you want.
Right-click column A header and choose Format Cells.
Choose Custom formatting and type 000000 in the custom format type textbox.
Click OK. Your cells will now show 000001, 000002, ... and so on.
In cell B1, type the following formula:
=INT(MOD($A1/(POWER(10, 7- COLUMN())), 10))
Copy B1 to columns C1 through G1.
Copy range B1:G1 to all subsequent rows B2:G999999 or whatever.
Notes
One advantage of this approach is that column A is numeric, not text, so you can enter any 6-digit (or less) integer in it directly from keyboard and the cells will update themselves correctly.
Column A will adjust number of leading zeros automatically for 6-digits or smaller numbers.
The formula simply divides the number in column A by 10, 100, 1000 and so on and then takes remainder by 10, to get the corresponding digit at that decimal place.
You can easily modify this formula to work with larger or smaller numbers. You simply need to replace 7 by (maximum number of digits in your number + 1).
Might be a bit easier with a VBA macro. Right-click the sheet tab, select View Code, paste the below code, and Run (F5)
Sub fill()
[a1:a999999] = "=text(row(), ""000000"")"
[b1:g999999] = "=mid($a1, column()-1, 1)"
End Sub
(Write this formula in Column A and extend it down to row 999999)
generating the series:
=RIGHT(10^6, 6-LEN(ROW(A1)))&ROW(A1)
Write this formula in Column B and extend it to Column G, then
extend the range of B1:G1 to B999999:G999999
Distributing digits
=MID($A1,COLUMN(A1),1)

Excel: Obtain a column by sorting anotr one values

I need to automatically obtain a sorted column of values from another given column values, like in the sample:
I have I need A unchanged, and also B obtained from A
A A B
-----------------
1 1 0
0 0 0
3 3 1
8 8 3
0 0 8
I mean if the values from A changes, the B should change accordignly...
Is that possible in MS Excel?
Here a sandbox and sample:
http://1drv.ms/1SkqMhS
If you put The formula =SMALL(A:A,ROW()) in B1 and copy down then the cells in B will be linked to the cells in A in such a way that the numbers in B will be the numbers in A in sorted order. This won't be efficient for larger ranges but will work fine for small to medium size ranges.
If you want the numbers to start in a lower row, say B2 because you have a header in B1, adjust ROW() to something like ROW()-1.
A word of warning: Use of ROW() can make a spreadsheet somewhat fragile in that formulas that involve it can change their meaning if rows are inserted or deleted or the block containing the formula is moved to somewhere else. Rather than using ROW(), there is something to be said for adding a helper column which numbers the data in A (which would then be in e.g. B) and referring to these numbers rather than small. For example, in:
If I put the formula
=SMALL($B$2:$B$5,A2)
In C1 and copy down, it works as intended. In response to a question you raised in the comments, I added still another column which gives an index where the corresponding value occurs. To do this I wrote in D2 (then copied) the formula
=MATCH(C2,$B$2:$B$5,0)
Of course. Highlight your range and in the Data tab, click "Sort", then you can choose how you want to sort your data:
If column B has information that is to be used with Column A (like next to A1 is "Car"), and you want to sort the whole table, based on Column A, then just select Columns A and B, then sort by column A.
Found the answer, thanks to John Coleman !
Just some minor details like cell value fixing (with $, like A$2)and the -1+ROW adjustment for the 1 header row!

Resources