I have two columns in my sheet (P and Q).
I created a column (AK) with two values in AK2 and AK3, and a column (AL) with two values. One in AL2 and one in AL3.
I am looking to match text in any row of P with one of the two in AK, then pull AL from the same row as the match in AK and populate Q with AL. I hope that makes sense.
This works to do what I want, but when I drag the formula down, it changes the value of each cell in the formula.
=VLOOKUP(P2,AK2:AL3,2,FALSE)
If I drag that down to Q3 it changes to
=VLOOKUP(P3,AK3:AL4,2,FALSE)
The only thing that should change for this formula to work, in my case, is P3.
Appreciate the assistance!
You need to freeze the rows with '$'. Something like =VLOOKUP(P2,$AK$2:$AL$3,2,FALSE).
You should look into relative vs. absolute references (see for example here), as they are pretty important when using Excel.
Related
Excel coding gurus, i'd like someone to land me a hand in a following problem:
What I have:
I have an Excel 2019. Not the 365 edition.
And I have an Excel table with 2 columns. Column I contains list of people. And each person in the I column has the country of his/her origin denoted in the correspondent cell of H column.
For a better view check this picture, plz.
And I have two drop-down enabled cells (K4 and L4).
K4 holds the list of all countries, presented in H col.
And L4 is supposed to have a list of people, avaliable in the col I
Now, the question is:
How can I code those K4 and L4 cells, so that when in K4 cell I select a country, then in the drop down list of L4 cell I'd get the list of only those people from the I column that have their country of origin equal to the one in K4?
I feel like it is possible to be done with those array-returning functions but I just can't wrap my head around it all.
I have it working like this so far.
The functions necessary for this are INDEX, MATCH, IF, IFERROR, and COUNTIF, which are all available in Excel 2019.
The only thing I'm struggling with (without 365) is that I can't figure out how to remove the white space for the dynamic range.
The formula in column 'E' is to make a unique list of the 'Country' column:
=IFERROR(INDEX($H$2:$H$20,MATCH(0,COUNTIF($E$1:$E1,$H$2:$H$20),0)),"")
This formula must begin at least in row 2, as it needs an empty space above it.
Column F is a similarly unique list of column I, but is dynamic based on the value in K4: *Now updated, see edit below
=IFERROR(INDEX($I$2:$I$20,MATCH(0,IF($K$4=$H$2:$H$20,COUNTIF($F$1:$F1,$I$2:$I$20),""),0)),"")
The validation in K4 is based on column E, and the validation in L4 is based on column F.
As I said, without O365 I can't figure out how to remove the white space, but this should at least work for you.
EDIT: I have had another look at this and figured out the whitespace issue:
Data validation for L4:
=INDIRECT("F2:"&"F"&(COUNTA(F:F)-COUNTIF(F:F," ")+1))
As a bonus, the data validation for K4 can be similar, in case you want to expand column H to include more entries:
=INDIRECT("E2:"&"E"&(COUNTA(E:E)-COUNTIF(E:E," ")+1))
This creates a list from F2 (which will always be our first value) and will expand dynamically as far down as column F has data, given that we change the formula in F2 to be:
=IFERROR(INDEX($I$2:$I$20,MATCH(0,IF($K$4=$H$2:$H$20,COUNTIF($F$1:$F1,$I$2:$I$20),""),0))," ")
Note that the character in the IFERROR of this formula and the COUNTIF of the previous is not a space, it's the character from Alt+255.
As a final nicety, adding some conditional formatting to cell L4 will make it so that selecting data in L4, and then changing the value of K4 (so that L4 is no longer valid) will return whitespace - which is really white text on a white background.
Conditional format formula for L4:
=NOT(IFERROR(ISNUMBER(SEARCH($L$4,TEXTJOIN(" ",1,F:F))),FALSE))
The following is my elaboration on #RGilchrist's answer that he presented above. His was the main idea thus all the credit goes to him too.
The functions, needed for this are INDEX, MATCH, IF, IFERROR, and COUNTIF, which are all available in Excel 2019.
The formula in column 'E' is to make a unique list of the 'Country' column:
=IFERROR(INDEX($H$2:$H$17;MATCH(0;COUNTIF($E$1:$E1;$H$2:$H$17);0));"")
For example, on the pic you can see a formula of the cell E2.
Some comments on this formula:
it should be entered into the cell by Ctrl+Shift+Enter as it is an array formula. And you can see that it is wrapped into curly brackets {}.
the formula needs to have at least 1 cell above it. In this case it is E1.
As you see on the picture - I've deliberately made my dataset sparce, not dence (it has empty rows). To work around having zero in the resultset one has to place 0 to the E1 cell.
on the picture my dataset is colored. That hints the fact that I've announced the dataset as a table. This would allow for some neat features like auto extending of the table should I add more rows to it. And that provides for some functionally neat addressing of the column in the dataset. In my locale the table-addressed following formula would be this:
=IFERROR(INDEX(Tab_1[Стовпець1];MATCH(0;COUNTIF($E$1:$E2;Tab_1[Стовпець1]);0));"") where Tab_1 is the name of the table I've announced. And [Стовпець1] is a name of the column in the table.
Column F is a similarly unique list of column I, but is dynamic based on the value in K4: =IFERROR(INDEX($I$2:$I$20,MATCH(0,IF($K$4=$H$2:$H$20,COUNTIF($F$1:$F1,$I$2:$I$20),""),0)),"")
All comments to previous formula are applicable to this one as well.
The data validation in K4 is based on column E, and the validation in L4 is based on column F. But in order to overcome empty space problem in resulting dropdown list the data validation should be based on a formula that uses OFFSET function.
So the data validation source for K4 would be
=OFFSET($E$2;;;COUNTIF($E$2:$E$10;"?*"))
The relevant screenshot is in my locale but the general interface should be familiar.
So, I got an excel with two sheets: Sheet1 and Sheet2, in which I transfer data from the first to the second using the formula: =IF(INT(+INDIRECT("Sheet1!A1"))< 42900,0,+INDIRECT("Sheet2!A1")) (the cells are custom format dd/mm/yyyy hh/mm/ss). In Sheet1, the cells are organized in groups made out of 6 columns (in this example, A being the first column within the group).
In Sheet2, when I drag the cell containing said formula to the cell on the right, the formula remains the same. I want so that when I drag the cell, A1 will become G1, basically incrementing the column "number" by 6 jumping to the next group of 6 columns.
Is there a way of doing this WITHOUT using any coding. I need to avoid coding at all costs in order to avoid further complications.
P.S. I apologize if my explanation and title are somewhat vague.
Enter below formula anywhere in Column 1 and drag/copy across (to right)
=IF(INT(INDIRECT("Sheet1!" & ADDRESS(1,FLOOR((COLUMN()-1)*6,1)+1)))< 42900,0,INDIRECT("Sheet1!" & ADDRESS(1,FLOOR((COLUMN()-1)*6,1)+1)))
This formula will refer to cells $A$1,$G$1,$M$1,$S$1,.....
If you have to use this formula in say Column B then change (COLUMN()-1) to (COLUMN()-2) and likewise for Column C,D,E,.... use (COLUMN()-3),(COLUMN()-4),(COLUMN()-5),.... respectively.
Ex.
column A is a formula that outputs an 8 digit ID from a prior delimited calculation. I want to vlookup that ID to a separate set of data, but it is not finding the ID when the lookup value is part of a formula.
Is there a way to paste the formula result as a value in column b?
I have a list of 3000+ IDs, so using the F2, F9 trick won't work, since I would have to do that cell by cell.
Would prefer not to use VBA, but if that is the only way, can someone help simplify that process (new to using VBA)
If you have data in column A based on a left function of a bunch of numbers, and just want that result in column B, all you have to do is put:
=Value(ColRow)
in Column B. Then you can look up the value in Column B via VLookUp.
I am an avid Excel user and personally tested this solution. Though it appears #Scott beat me to it in the comment section.
quick excel question:
If I put values in cell B1 and B2.
Then write the following formula in cell A1:
=$B$1-$B$2
then I highlight cells B1 and B2 and move them to column C. the formula in A1 automatically adjusts for the move ie. formula now becomes:
=$C$1-$C$2
How would I get it to stick to column B and not switch to column C. I tried searching google but did not get right answers (probably am not phrasing question correctly).
The context of my problem is that formulas in one sheet are being calculated based on month end data which is placed in another sheet. Now I need to add April month end data. So I shift the old data to the right and input April's data, but the formulas are automatically adjusting for the shift and still refer to March's month-end data. This despite the formulas using absolute referencing.
Thanks for any help provided
The formula you are looking for is
=INDIRECT("B1")-INDIRECT("B2")
This will always refer to Cells B1 and B2 regardless of what you to do move the cells or add new columns etc.
This will allow you to simply insert a column for the new month.
Not a good spreadsheet design, you should really add new data to a new column.
However, if you are determined to stick to that design, copy and paste the old values to a new column, then delete the originals. Formulas will not be alterd by that.
I have a spreadsheet with 4 columns : A, B, C, D.
I want to calculate the difference between A-B and C-D. So in cell E2 I enter the formula =A2-B2 , and get the result that I want, which is the difference between A-B.
Now I drag the formula in E2 to cell F2, expecting that Excel will "think" that now I want the difference between C-D. However, when I drag the formula from column E to column F I get =B2-C2 (you see, Excel assumes I want to use B2 again).
My question is: how can I make Excel “understand” that I want to use =C2-D2 after =A2-B2, and NOT =B2-C2?
This an abbreviated example. The original data-set has hundred of columns. Thanks for your help.
Enter Formula in E2
Drag the formula up till G2. Now G2 will have the formula which you want.
Delete Col F. Now Col G will move to Col F, which will have your required formula
There's no way in the UI that you get Excel to "think" that much - it'll only shift the references by one column if you drag it across. If deleting the columns in between is not an option, you need to rewrite you formula, e.g.:
=OFFSET(A1,0,COLUMN(L1)-COLUMN($L1))-OFFSET(B1,0,COLUMN(L1)-COLUMN($L1))
In this example, it is assumed that you start showing the difference in column L - of course you need to adjust according to your worksheet - but once done, you can drag the formula to the right as far as you need.
As your original data-set has hundreds of columns, you may want to use a non-volatile formula, eg:
=INDEX(A1:K1,1+COLUMN(L1)-COLUMN($L1))-INDEX(A1:K1,2+COLUMN(L1)-COLUMN($L1))
This will speed up calculations in the workbook. Depending on how big the data-set is and how many other formulas are in the workbook, the difference in speed could be enormous.
The same conditions apply as in Peter's example.