Excel: How to auto-populate cell with data using static column with a row dependent on another cell? - ios

I've got an spreadsheet with hundreds of problems listed out that map to a smaller number of solutions. I want to use this data to generate a drop down that selects the problem from a data range, and then next to it, another cell that populates the solution from one row over.
Example:
Column A Column B
Issue 1 Solution 1
Issue 2 Solution 4
Issue 3 Solution 5
Issue 4 Solution 1
Issue 5 Solution 1
Issue 6 Solution 3
Issue 7 Solution 2
If I want to create two cells where the first one is a drop down list (A1:A7), how can I make the second cell populate using a static column (B), but with a dynamic row number based off the first cell. So if someone chooses Issue 6 from the dropdown (A6) the second cell will know to populate Solution 3 (B6)?
Thnaks

To do this, you need two steps:
1) For the first cell where you'll have the dropdown option, click on Data Validation command (under the Data ) In the Settings menu in the dialogue box, click on "list" and set the Source to the Column A cells (without the header). This will make these the options in the drop down menu
2) For the second cell where you'll have the solution automatically change depending on the first cell, you'll need to use the vlookup function. The syntax looks like this: VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
In this case, the lookup_value will be the first cell, the table array will be your original table (without the headers), the col_index_num will be 2 (which means it will take the answer from the second column), and range_lookup will be FALSE (which means it will look for an exact match)
If you want more information about either one of these steps, here's the official help sections for Excel 2010: Create a drop down link , Vlookup

Related

Change cell value based on checkbox in Google sheets

I'm using Google sheet to manage my budget (see sample below) where I add each of my expenses as a single entry (yes, sounds like a lot of work). I sometimes split the expense with my roommate but then I have to add the value and divide by 2 everytime.
I was thinking if I could use a checkbox next to the value that will automatically divide the expense number by 2 when I check it. Is this possible?
I'm open to simple suggestions other than the checkbox to automatically update the value. Thank you.
Using simple IF formula you can just check if the checkbox is true, if it is then it will divide the current value on column C by 2. Otherwise it will remain blank.
Formula:
=IF(D1,C1/2,"")
Drag down to other cells.
Result:
Suggestion, Alternate solution:
If you'd like you can make a table with a column for your roommate, instead of editing the actual column so you can see both values. And use this formula:
=if(NOT(D2=""),E2/2,E2)
You have a column for per head contribution/split. If the cell on roommate is blank then it will stay as the total value, if roommate has an additional then it will be added to total and split it by 2.
Or using arrayformula:
=arrayformula(if(NOT(D2:D=""),E2:E/2,E2:E))
Works the same as above you just have to fill the enter the formula in the first cell no need to drag down and it will automatically expand to rows/cells below just make sure that below cells are empty or it will return an error.
Additional - Using same cell
As you've mentioned in the comments. Here's a way to divide the original value without using another cell to store it. (Not recommended)
Formula:
=VALUE/IF(D1,2,1)
example:
=1000/IF(D1,2,1)
Result:
However, I do not recommend this. It is still best to make use of another cell to store the original value before making calculations to it.
Also, using this formula you have to change the value from the formula and not on the cell otherwise you will replace the actual formula.
You can try array approach-
=ArrayFormula(IF(D1:D,C1:C/2,C1:C))

How do I format a cell, only when it's not empty, based on the input of another cell?

I'm working on a spreadsheet in Google Sheets for multiple people, and indicate in a column who the person the information on that row pertains to. I want to format cells on that column, only when they're not empty, based on what person is selected in another cell.
I can create functions to format things based on another cell's entry, but I don't know how to compound that with a function for not being empty. Sorry if this is super basic, I just can't figure it out.
Yep. This is a super simple thing to do.
1) Highlight the column where the person's name appears.
2) From the main menu, select Format, Conditional formatting.
3) In the sidebar click add a new rule. what you want to do is create one rule for each name that appears (or could appear) in that column.
4) Under "Format cells if, select "Text is exactly"
5) Type the name in the cell where it says Value or Formula
6) Choose a background colour to suit.
7) Click Done.
8) Repeat steps 3 to 7 for each person; but change the background colour in each case.
Here's an example.

Formula missing when Adding Rows in Google Sheets

I have made a simple formula, based on cells in the same row, to indicate to the user that they have entered enough information - and it works as needed .
=IF(AND(ISTEXT(B20),ISNUMBER(C20),ISNUMBER(E20),ISTEXT(F20)),"Ok",IF(AND(ISBLANK(B20),ISBLANK(C20),ISBLANK(D20),ISBLANK(E20),ISBLANK(F20)),"","MORE INFO"))
However, when I click the built in "add more rows" button at the bottom of the sheet the formula is not present in the new cell - but any dropdown menu or validation I've used in the cells not containing the formula are present in the respective added cells of the new row. Any Ideas why just the formula is missing ? Thanks.
Thanks to GimelG at Google Docs Forum..........
When you add additional rows, Sheets assumes you want to continue the same dataset and, therefore, applies the existing formatting as well as Data Validation. It does not, however, copy formulas automatically as that would be adding actual new data to your sheet.
You can use an ArrayFormula version of your formula to populate the entire column, which it would continue to do as you'll add more rows of data. Assuming your data starts at row 2 (below the header), try this:
=arrayformula(if(istext(B2:B)*n(C2:C)*n(E2:E)*istext(F2:F),"Ok",if(len(B2:B)+len(C2:C)+len(D2:D)+len(E2:E)+len(F2:F),"MORE INFO",)))

Apply formula to the entire column

I'm changing all the zip codes from Column A into Column B with the formula:
=TEXT(A1,"00000")
Like this:
I want every cell in Column B to be transformed using the formula above. But I have over 40,000 rows, so it is not feasible to drag the formula down to apply it to the entire Column B because it takes so long.
Are there any alternatives to dragging?
It looks like some of the other answers have become outdated, but for me this worked:
Click on the cell with the text/formula to copy
Shift+Click on the last cell to copy to
Ctrl + Enter (Cmd + Enter on Mac.)
(Note that this replaces text if the destination cells aren't empty)
I think it's a more recent feature, but...
Double clicking the square on the bottom right of the highlighted cell copies the formula of the highlighted cell.
I think you are in luck. Please try entering in B1:
=text(A1:A,"00000")
(very similar!) but before hitting Enter hit Ctrl+Shift+Enter.
This is a shortcut for wrapping the formula with ArrayFormula():
=ArrayFormula(text(A1:A,"00000"))
This worked for me:
Input the formula in the first cell.
Press Enter.
Click on the first cell and press Ctrl + Shift + down_arrow. This will select the last cell in the column used on the worksheet.
Ctrl + D. This will fill copy the formula in the remaining cells.
This is for those who want to overwrite the column cells quickly (without cutting and copying). This is the same as double-clicking the cell box but unlike double-clicking, it still works after the first try.
Select the column cell you would like to copy downwards
Press Ctrl+Shift+⇓ to select the cells below
Press Ctrl+Enter to copy the contents of the first cell into the cells below
BONUS:
The shortcut for going to the bottom-most content (to double-check the copy) is Ctrl+⇓. To go back up you can use Ctrl+⇑ but if your top rows are frozen you'll also have to press Enter a few times.
For Mac:
Click on the first cell having the formula and press Ctrl + Shift + down_arrow. This will select the last cell in the column used on the worksheet.
Command + D
(don't use ctrl). This will fill the formula in the remaining cells.
Let's say you want to substitute something in an array of string and you don't want to perform the copy-paste on your entire sheet.
Let's take this as an example:
String array in column "A": {apple, banana, orange, ..., avocado}
You want to substitute the char of "a" to "x" to have: {xpple, bxnxnx,
orxnge, ..., xvocado}
To apply this formula on the entire column (array) in a clean an elegant way, you can do:
=ARRAYFORMULA(SUBSTITUE(A:A, "a", "x"))
It works for 2D-arrays as well, let's say:
=ARRAYFORMULA(SUBSTITUE(A2:D83, "a", "x"))
Found another solution:
Apply the formula to the first 3 or 4 cells of the column
Ctrl + C the formula in one of the last rows (if you copy the first line it won't work)
Click on the column header to select the whole column
Press Ctrl + V to paste it in all cells bellow
Just so I don't lose my answer that works:
Select the cell to copy
Select the final cell in the column
Press CTRL+D
You can use Ctrl+Shift+Down+D to add the formula to every cell in the column as well.
Simply click/highlight the cell with the equation/formula you want to copy and then hold down Ctrl+Shift+Down+D and your formula will be added to each cell.
The exact formula is:
=ArrayFormula(text(A1:A,"00000"))
ArrayFormula works on multiple rows (in the above example, every row), and results are placed in the cell with the formula and the cells below it in the same column. It looks as if the same formula was copied into all those rows.
If any of the cells in that column are not empty, they won't get overwritten. Instead, you will get an error message.
To save yourself typing, you can use the trick from the answer above by pnuts:
Type: =text(A1:A,"00000") and then hit the following key combination:
On windows: Ctrl+Shift+Enter
On a MAC: Command+Shift+Enter
This will convert the formula to ArrayFormula.
After hitting the key combination, you need to hit Enter, to actually apply the converted formula.
If your sheet contains header row(s), and you want to apply formula from (for example) row 5 on, you would use =text(A5:A,"00000") instead.
This answer includes information from pnuts's answer and LOAS's comment.
Lambda Solution
Using the new LAMBDA and MAP functions, this is now doable without an ArrayFormula or having to drag anything.
=MAP(A2:A6, LAMBDA(value, TEXT(value, "00000")))
LAMBDA defines a function. value is the parameter, which we can use in the formula expression.
MAP applies the LAMBDA to each value in the given range. This also works on 2D ranges.
To be clear when you us the drag indicator it will only copy the cell values down the column whilst there is a value in the adjacent cell in a given row.
As soon as the drag operation sees an adjacent cell that is blank it will stop copying the formula down.
.e.g
1,a,b
2,a
3,
4,a
If the above is a spreadsheet then using the double click drag indicator on the 'b' cell will fill row 2 but not row three or four.
Well, Another easiest and simplest way is as in my file rows were above 16000, which is pretty huge number. So steps which helped me are:
1. Select the cell in which formula is written.
2. Then go to NameBox(it is the box which tells about active cell). Here in my case it was the cell where was formula was written(i.e P2).
3. Then in that cell type your active cell number:your last row.For example last row of my column was 16745 and formula was written in P2.
So write P2:P16745,
4. Press Enter in Name Box and bingo your whole area of column till last row is selected.
5. Now press Ctrl+D(Windows)
try:
=INDEX(TEXT(A2:A; "00000"))
advantages: short, works, smells nice
to map out empty cells you can do:
=INDEX(IF(A2:A="";;TEXT(A2:A; "00000")))
Reading the answers here did not quite work for me, but a combination did. Here are my steps (Windows, Chrome):
Select the cell with the formula you want to apply to the column (for the whole column, ensure this is the top cell)
Ctrl + Shift + Down (selects all below cells)
Ctrl + D (apply formula)
Done!
Based on:
https://stackoverflow.com/a/61112723/3200858
https://stackoverflow.com/a/51411774/3200858
You may fill the column by double-clicking on the bottom right hand corner of the cell which you want to copy from (the point on the box that you would otherwise drag) and it will be applied to whole column.
NB: This doesn't work if you have the filter applied, nor if there is already something already in the cells below.

Google Spreadsheet - Populate a cell based off different cells content, and use a third cells value

Is it possible to fill a cell with data from another cell based off the content of a different cell? I have a drop down menu in one cell, and when I select something from that menu, I would like the cell next to it to search a database on that sheet that the drop down is based off of. it has a second row with different values I would like to appear in the next column. I think about it, and it should seem easy, but I'm having troubles explaining it.
You could use VLOOKUP() to search the list based on the dropdown cell value. Ref

Resources