Trying to import cell data based on cell drop down - excel

I'm trying to re-do a spreadsheet.. Without having to put an =if into every cell where the data would be variable depending on the selection of a drop down (Which is how it is set currently :( )
On the main sheet.. Cell J1 i have a dropdown selection.. And im looking for the cells in
A1-F1 to be populated with the information on the data sheet.. Based on the selection either 1 or 2 in this example but i cant figure out how to do this
Any help would be appreciated

This is what VLOOKUP functions are for. VLOOKUP functions search for a key in the first column of a range, and matches the selected row on it.
You can just put =J1 into your A1 cell, and on your B1 cell you can search for A1 as =VLOOKUP($A1,Data!$A$1:$F$2,2,FALSE). This formula can be read like this:
"Please, search for the value that it's in $A1 in table Data!$A$1:$F$2.When you got it, get me the column 2. Ah, by the way, if you asked me if the key column is made of sorted numbers, so if you can't find it, you can extrapolate linearly, I'd answer FALSE, got it? Thanks a bunch!"
So, in your C1 cell you'd ask for the column 3, and so on. Of course, if you'd like to just create a single formula, you can insert a row over your row 1, and put the column references over the cells, as this:
In this case, my formula on B1 is =VLOOKUP($A2,Data!$A$1:$F$2,B1,FALSE) - which can be dragged to C1:F1. Of course you can later hide the row 1 from your user.
Hope that helps.

Related

Check if a row contains a negative value, if so, insert that cells first row in specific column

I am trying to figure out something I am not sure can be done with formula's alone (hence the tag of VBA as I am open to VBA-related answers).
As you can see in the screenshot below, I have a column I, in cell I2 (and from I2 onwards, I3, I4 etc) I want to check that cells row (I2 -> J2, K2, L2 etc) and when I find the first negative value, the formula inserts that specific cells first row in that column, in this case, the date of that column.
I am currently using the following formula: =IF(COUNTIF(J2:BJ2,"<0"),"Yes","No")
However, I was not sure how to insert the first negative values date, as you can seen in the next screenshot.
I would like my data to look like the following:
Anyone got any ideas? or is this a VBA task?
INDEX/MATCH will do the trick. Wrap it in IFERROR to return the "No" result.
INDEX($J$1:$M$1,MATCH(TRUE,INDEX(J2:M2<0,),0))

Fill spreadsheet table with list of names

I need to fill an empty table (from an excel spreadsheet) with a list of values from a list of 13 values (names I have written in a different sheet) always in the same order. For example
Spreadsheet
Is there any way to do it without using a Macro? If there is no other way, then a Macro would be OK. I tried many things for weeks and I cannot figure it out :(
Thank you very much!
You can use this formula in the range C2:G9:
=Index( Sheet2!$A:$A ,Mod(Row()*5+Column()-13,CountA( Sheet2!$A:$A ))+1)
just replace Sheet2!$A:$A with the column or range where the names are.
( -13 is short for -ROW(C2)*5+COLUMN(C2) where C2 is the first cell where the names will be )
Okay, so it's a bit convoluted but I'll pull it into parts for now:
Add a new sheet:
in Column A put the list of names, make sure that cell A1 has heading of NAMES
in B2 put:
=Counta(A:A)
In cell C2 put 2
In Cell D2 put =IF(C2+1>$B$2,1,C2+1) - fill this across to G2
In Cell C3 put =IF(G2+1>$B$2,1,G2+1)
Then Fill this down as far as needed.
Then in Cell I2 put =HLOOKUP($A$1,$A:$A,C2,FALSE)
You can see here why we need the "header" row in A1
Fill this down as far as needed.
Example of how it looks with outputs:
Example where you can see the formula:
Now you can replace names, Add new names to the List of names etc, and it will keep the order and pattern.
I thought about putting all the formula into one cell, but for clarity have left them separate.

Vlookup to check two conditions

I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!
you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)
Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"
You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.

I have a column in Excel which gets data from another column, in another spreadsheet. How do I add an empty row after every cell?

As the title suggests, I have a column in my first worksheet which gets its data from another column, in a second spreadsheet.
I have linked them using ='Data'!B1
Of course, if I drag the handle down, I get all the remaining data from the linked column, but I would like to have an empty row after each cell.
Like so: B1 has data, B2 is blank, B3 has data, B4 is blank, etc.
If some kind person out there could help me out, I would appreciate it very much. I have tried macros and looked this up in forums but can't seem to make this work with Data --> Sort.
Thank you! :)
Given what you're asking for, the way I would do it would be using the Offset or Indirect function so I can control which cells to pull in from the other sheet.
Given your example, in Sheet1, I would have:
B1: =OFFSET(Sheet2!$B$1,(ROW(B1)-1)/2,0)
B2: <blank>
B3: =OFFSET(Sheet2!$B$1,(ROW(B3)-1)/2,0)
B4: <blank>
You can drag this down and it will give you alternating formula / blanks and pull the consecutive row from the other sheet.
As a quick explation, the function will always look at cell B1 in your second sheet and offset it by (Row()-1)/2 rows... So, in row 1, it would offset it by (1-1)/2 = 0 rows, in row 3, it would offset it by (3-1)/2 = 1 rows, etc.
Hope this makes sense and does the trick!!

Excel: Find intersection of a row and a column

My question is how can I find an intersecting cell of a specific column and row number?
My situation is this: with some calculations I find two cells, lets say B6 and E1. I know that I need a row of the first one and a column of the second one. So I could just use ROW and COLUMN functions to get the numbers. After that, I need to find an intersecting cell. Which would be E6 in this example.
I would just use INDEX(A1:Z100;ROW;COLUMN) but I don't know the exact area that I'm going to need - it depends on other stuff. I could use something like A1:XFG65000 but that is way too lame. I could also use a combination of INDIRECT(ADDRESS()) but I'm pulling data from a closed workbook so INDIRECT will not work.
If this would help to know what is this all for - here's a concrete example:
I need to find limits of a section of a sheet that I would work with. I know that it starts from the column B and goes all the way down to the last non-empty cell in this column. This range ends with a last column that has any value in first row. So to define it - I need to find the intersection of this last column and the last row with values in B column.
I use this array formula to find the last column:
INDEX(1:1;MAX((1:1<>"")*(COLUMN(1:1))))
And this array formula to find the last row:
INDEX(B:B;MAX((B:B<>"")*(ROW(B:B)))
Last column results in E1 and last row results in B6. Now I need to define my range as B1:E6, how can I get E6 out of this all to put into the resulting formula? I've been thinking for a while now and not being and Excel expert - I couldn't come up with anything. So any help would really be appreciated. Thanks!
You can use an Index/Match combination and use the Match to find the relevant cell. Use one Match() for the row and one Match() for the column.
The index/match function to find the last cell in a sheet where
column B is the leftmost table column
row 1 is the topmost table row
data in column B and in row 1 can be a mix of text and numbers
there can be empty cells in column B and row 1
the last populated cell in column B marks the last row of the table
the last populated cell in row 1 marks the last column of the table
With these premises, the following will return correct results, used in a Sum() with A1 as the starting cell and Index to return the lower right cell of the range:
=SUM(A1:INDEX(1:1048576,MAX(IFERROR(MATCH(99^99,B:B,1),0),IFERROR(MATCH("zzzz",B:B,1),0)),MAX(IFERROR(MATCH(99^99,1:1,1),0),IFERROR(MATCH("zzzz",1:1,1),0))))
Since you seem to be on a system with the semicolon as the list delimiter, here is the formula with semicolons:
=SUM(A1:INDEX(1:1048576;MAX(IFERROR(MATCH(99^99;B:B;1);0);IFERROR(MATCH("zzzz";B:B;1);0));MAX(IFERROR(MATCH(99^99;1:1;1);0);IFERROR(MATCH("zzzz";1:1;1);0))))
Offset would seem to be the way to go
=OFFSET($A$1,ROW(CELL1)-1,COLUMN(CELL2)-1)
(The -1 is needed because we already have 1 column and 1 row in A1)
in your example, =OFFSET($A$1,ROW(B6)-1,COLUMN(E1)-1) would give the value in E6
There is also ADDRESSS if you want the location: =ADDRESS(ROW(B6),COLUMN(E1)) gives the answer $E$6
The following webpage has a much easier solution, and it seems to work.
https://trumpexcel.com/intersect-operator-in-excel/
For example, in a cell, type simply: =C:C 6:6. Be sure to include one space between the column designation and the row designation. The result in your cell will be the value of cell C6. Of course, you can use more limited ranges, such as =C2:C13 B5:D5 (as shown on the webpage).
As I was searching for the answer to the same basic question, it astounded me that there is no INTERSECT worksheet function in Excel. There is an INTERSECT feature in VBA (I think), but not a worksheet function.
Anyway, the simple spacing method shown above seems to work, at least in straightforward cases.

Resources