My VLOOKUP command is like this for column-D, row-3 in Sheet1:
=VLOOKUP(Sheet1!C3, ABBREV!B2:BA8791, 2, FALSE)
I search for 'Sheet1!C3' in the first column of 'ABBREV!B2:BA8791', and if there is exact match I return with a value in column '2'.
Above works for the selected cell D3. But how to propagate this to more cells below it (~10000) quickly changing the formula only at C3? i.e. For D4 I only need C3 changed to C4 in the above formula. Dragging the corner of the cell doesn't work. Selecting all the cells I want to populate and entering ctrl+Enter changes the range in C3 as well as the ranges in ABBREV in the formula. Using ctrl+Shft+Enter doesn't change C3 to C4.
as pnuts said, you should use static address for your source table, change your code to
=VLOOKUP(Sheet1!C3, ABBREV!$B$2:$BA$8791, 2, FALSE)
when Excel copy formula, it will change addresses to make best representation to your needs, but changing the source table that you are looking into it will make error in some earlier lookups that you have change ABBREV!B2:BA8791 to ABBREV!$B$2:$BA$8791.
using ABBREV!B:BA not suggested as we don't know that in ABBREV sheet, you have just one table or more, and it can cause wrong results.
using $ before each ROWs or COLUMNs tells excel to don't change this ROW or COLUMN automatically. for example you can use $C3 in your code to tell excel to change 3 if row changes, but don't change C if column changes. of curse this is not necessary right now, and I used it as an example.
Related
I am looking to do a kind of automatic cell updates on excel, which is a status update for a product we got and the location of the product in the warehouse.
I have basic knowledge of VBA and I didn't manage to code anything to help me with that. I tried to use If function, but didn't make sense because I can't find a way to achieve what I need.
Here is sheet 1
and sheet 2
examples.
This is what I am trying to achieve:
if a cell within Sheet2 column A range = Cell A2 in sheet 1, then fill Sheet1, B2 cell and Sheet1, C2 cell with the information from sheet2 on the condition that it is the most recent entry (in the example images it is the entry with the dispatched status)
Would you recommend VBA or using formulas, and if so what should I do?
This can be done with formulas, however getting the latest value isn't as easy as it seems. This can be achieved however by following this tutorial for reference. I especially refer to the part using LOOKUP(.
Other than that, all you need to do is set your ranges to refer to the correct sheet.
=IFNA(LOOKUP(2,1/(Sheet2!A:A=Sheet1!A2),Sheet2!B:B),"")
My formula in B2 is:
=INDEX(Sheet2!$B:$B;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
My formula in C2 IS:
=INDEX(Sheet2!$C:$C;MAX(SI(Sheet2!$A:$A=Sheet1!A2;ROW(Sheet2!$A:$A)-MIN(ROW(Sheet2!$A:$A))+1)))
Both formulas are array formulas so instead of entering them with ENTER, they must be entered pressing
ENTER+CTRL+SHIFT at same time
Anyways, these formulas will probably make your file heavy and slower. Think about redesigning the way you save data, and consider adding a date field, and resuming data with Pivot Tables.
I'm using Index-Match to match Full Names with head count in that party.
I have it working but it uses both the structured and explicit cell reference.
I can't figure out why when I add a new row in my table, the column with the index-match formula wont populate the last row.
This is the formula used:
=IFNA(INDEX(AA:AA,MATCH([#[Preferred Seating 1st Choice]],D:D,0)),"")
Column AA has the head count number and column D has the list of full names.
Preferred Seating is the column used to reference the search.
I looked around and can't seem to find why it wont fill in the last row after that rown info is entered.
I can only assume it has something to do with the mixed Explicit-structured cell/column references. Any help please.
Yes Excel may not automatically assume a formula needs to be automatically filled in an entire table column if it contains unusual references. Unless you have data outside the table, you should just refer to the columns in the table:
=IFNA(INDEX([Column AA Name],MATCH([#[Preferred Seating 1st Choice]],[Column D Name],0)),"")
These can be easily entered when editing the formula by selecting all cells in the source columns excluding the heading. The formula will always use the entire
source columns and the formula should automatically fill its own entire column.
You can also control whether a column automatically has its formula updated through a hidden property. The ability to change the behavior of the column only appears through the front end when you're making changes to the column.
After entering a formula in a column, Excel will either automatically fill the entire column and give you the option to turn off the automatic fill, or Excel will not automatically fill the entire column and give you the option to turn it on.
After entering a formula that isn't being filled, this icon will appear:
Click it and then select to Overwrite all cells in this column with this formula
Deleting a formula from one cell in a column that is being automatically filled will turn off the automatic fill. Double clicking a cell with a formula and pressing enter will give you the option to turn it on again.
The title pretty much says it. I need to transfer certain cells from one cell to another without the coordinates of the cells changing after an insert operation.
In ex., I want the value of cell B3 of Sheet1 to transfer to cell A2 of Sheet2. If I insert a column on the left of B3, the previous B3 will become C3 and you now have a new B3 in which you can add a new value. I want my A2 to still receive the value of B3, but the new B3, not the old B3 with is now C3.
If I go with +Sheet1!B3, after the insertion of the column it will become +Sheet1!C3. I want it to remain to +Sheet1!B3.
I tried with $, +Sheet1!$B$3, but it still changes.
You can use the indirect function in excel.
+INDIRECT("Sheet1!B3")
With the caveat that you never change the location of column A you could do the following:
=INDEX(Sheet1!$A:$$ZZ,ROW(B3),2)
Caveat: as set up will only work for cells between and including columns A and ZZ. the ZZ reference will increase as columns get added. If you have columns outside of ZZ initially, then you will have to adjust the final column reference to suit your needs.
INDEX gave me some errors in the function (probably on my end), but I managed to solve it using INDIRECT.
Ty for the feedback, #AlexCollins #ForwardEd
I have this table that is made from reference to other table.
and now I want to sort from small to largest the third column, but since it is referenced from another table is not sorting. And I also dont want excel to sort the reference table and I need the table to be referenced because I will change some values on the reference table and I need them to be connected, so I just cant copy and paste the values and then sort.
Could you give me some help?
Ok, I went ahead and built a small example:
The formulas are as follows:
The 3 in Row 20 are to be copied downwards with PasteSpecial>Formulas:
in E20: =IFERROR(RANK($D20,$D$20:$D$33,1),"")
in F20: =IF(ISNUMBER($D20),"",(COUNTIF($D$20:$D$33,"<"&$D20)+1)+COUNTIF($D$20:$D20,$D20)-1)
in G20: =IF($E20="",(MAX($E$20:$E$33)+$F20),$E20)
The formula in B3 is to be copied into the whole target table with PasteSpecial>Formulas:
in B2: =INDEX(B$20:B$33,MATCH(ROW()-1,$G$20:$G$33,0),1)
Please let me know if you have any questions!
This method only works if the entries in the column you are sorting on are unique. You will need to adjust the address ranges to suit your data.
The formulas in the each column start from X and finishing in Z as you move left are as follows:
=INDEX($X$41:$X$47,MATCH(ROWS($Z$29:Z29),COUNTIF($Z$41:$Z$47,"<="&$Z$41:$Z$47),0))
=INDEX($Y$41:$Y$47,MATCH(ROWS($Z$29:Z29),COUNTIF($Z$41:$Z$47,"<="&$Z$41:$Z$47),0))
=INDEX($Z$41:$Z$47,MATCH(ROWS($Z$29:Z29),COUNTIF($Z$41:$Z$47,"<="&$Z$41:$Z$47),0))
Note only the range right after INDEX is changing. Thes are CSE or array formulas. It means you need to press CONTROL+SHIFT+ENTER when you are done editing your cell. Then copy the individual cell and paste it in the rows below the copied cell. pasting including the source cell or dragging down MAY not work. Repeat this for all three columns.
Proof of concept
I am attempting to use an IF statement to check whether the sum of two cells from another Excel sheet is greater than or equal to 1.
For a sheet called Test1 with the values of interest in column C, this is what I have so far, which works fine:
=IF((Test1!C1+Test1!C2>=1),1,0)
In column B on a second sheet that I'll call Test2, I want to copy this formula down 200,000 rows. However, if the aforementioned formula is in cell B1, for the formula in B2 I would like the formula to read:
=IF((Test1!C3+Test1!C4>=1),1,0)
I want to copy the formula down the column so that the second cell reference in the formula in the first row does not become the first cell reference in the formula in the second row (eg. it would go C1+C2, then C3+C4, C5+C6, etc.).
I have tried manually entering the formula for a few rows, highlighting those, and copying them down but can't get the desired cell reference pattern. If I highlight and drag these first three formulae down another three rows, C4 and C5 are repeated and not in the correct pair.
=IF((Test1!C1+Test1!C2>=1),1,0)
=IF((Test1!C3+Test1!C4>=1),1,0)
=IF((Test1!C5+Test1!C6>=1),1,0)
=IF((Test1!C4+Test1!C5>=1),1,0)
=IF((Test1!C6+Test1!C7>=1),1,0)
=IF((Test1!C8+Test1!C9>=1),1,0)
I have tried using OFFSET() within this formula but couldn't get it to work. I am basically just wanting to add 1 to each of the cell references in the formula, as compared to the previous row (but not to actually add 1 to the value of that cell, as would happen with C1+1 for example).
Any insight would be greatly appreciated!
If you plan on copying this down 200K rows then you will want the absolute simplest formula that accomplishes the stagger. Avoid the volatile OFFSET function or be prepared to spend a lot of time waiting for random calculation cycles to complete. A volatile function will recalculate whenever anything in the workbook changes; not just when something changes that involved the formula in the cell.
=--(SUM(INDEX(Test1!C:C, (ROW(1:1)-1)*2+1), INDEX(Test1!C:C, (ROW(1:1)-1)*2+2))>=1)
The following formula should do the trick:
=(SUM(INDIRECT("C"&ROW()*2-1);INDIRECT("C"&ROW()*2))>=1)*1
And that's the version using IF:
=IF(SUM(INDIRECT("C"&ZEILE()*2-1);INDIRECT("C"&ROW()*2))>=1;1;0)
You say I am basically just wanting to add '1' to each of the cell references in the formula but appear to be incrementing by 2, so I am confused but an option might be to apply you existing formula to 400,000 rows, together with =ISODD(ROW()) in another column, then filter on that other column to select and delete those showing FALSE.
Excel's autofill won't do the 2-cell shift that you're looking for. You can use the functionality that is there.
Put =IF((Test1!C1+Test1!C2>=1),1,0) in the top cell and drag a copy to the second row (it will be =IF((Test1!C2+Test1!C3>=1),1,0) but that's okay). Now, put 'A' and 'B' in the next column. Select all 4 cells and copy them down 400k rows.
Use filter to delete rows flagged with 'B' and delete the blank rows.
(Select blank rows with [F5] click Special and select Blanks, then right-click and delete)
Here is all you need. It's fast and nonvolatile.
=--(SUM(INDEX(Test1!C:C,ROW(1:1)*2-2):INDEX(Test1!C:C,ROW(2:2)*2-2))>=1)
Copy it down as far as you like.