Assign a value to a variable [Excel] - excel

I'm making a basic inventory list for my place of work and want to make it easier for future inputs and changes. So far I have inputted all of the model numbers for our inventory, and I was wondering how I could assign a price to the model number, so that it automatically fills it into the cell two cells right. I'm also working with around 50 model numbers, so it would be a lengthy function.
Example:
B E
778740 125.99
778739 120.99
778740
Is there a way that the second "778740" could be automatically filled in? I'm fairly new to excel and I can't find this problem, although I know it is very simple and exists. Even if some one could link me it that would be very much appreciated. Thank you!

Suppose your headers are in row 1, model numbers in column A and prices in column B. You could use the following formula in cell B3 and drag it on down as far as you need. Then what you fill in in column A matches something above, the cell next to it will automatically populate. And otherwise it stays blank, letting you know it is on you to fill it in (though once you do, the formula will no longer be there, so if you later fill in a match above, the magic is gone).
=iferror(indirect("B" & (1+match(A3,A$2:A2,0))),"")
The match function returns an error if nothing is found, and ifError will handle that by leaving your cell blank. If a match is found, we get the value from the corresponding row in column B.

Related

Two formulas I'm having issues with

this is my first time asking a question here, but I have two formulas that I'm not really sure why they aren't working.
The first issue I'm having is with this formula:
=MAX(IF(C46:C51<80,B46:B51))
Any reason that this formula returns #VALUE! I'm supposed to find the max value of data in column B so long as the data in column C is less than 80.
Then I'm having issues with VLOOKUP on two questions, that are related I have a large dataset on a separate worksheet. I need to VLOOKUP someone's name to find a value associated with that name. The problem is that their name comes up multiple times. The formula I have for it so far is:
=VLOOKUP('PDR DATA'!E80,'PDR DATA'!A4:V119,15,FALSE)
Where 'PDR DATA'!E80 is the first instance of the person's name appearing. However, using FALSE with VLOOKUP returns #N/A, but if I use TRUE it returns the very last value from column 15 even though the name is different from what I'm searching for. I'm lost here and don't know where to turn.
=MAX(IF(C46:C51<80,B46:B51,C46:C51)) works for me. (Please ensure B46:B51 & C46:C51 has integer values)
=VLOOKUP(cell you want to lookup for, cells where you want to lookup(maybe more than one column), which column you want to fetch from (number), rangelookup) try to understand the syntax and give your inputs
ex: If I have a existing data with Name and id in sheet2, need that id in sheet1 by using the name then I will use =VLOOKUP(L2,Sheet2!A2:B5,2,TRUE)
L2 is the sheet1 name, then I have selected both columns(A,B) and rows in sheet2, then column number is 2.

VLookUp with Nested SUMIFS

I have been trying to make a form for some of my team members who are not that computer literate, and I essentially want to make it click and go. I thought I could do it...but alas I am not as good with nesting functions as I thought I was.
I have this spreadsheet where I want to put data into the yellow cell. On the next sheet I have the below table. What I want to do is use a formula to fill H4 with the "Request Branch's" Account Number. Now, I have currently filled the cells with information. They, in fact, have drop down options - which are pulled from the Account List table. As a result the value in H4 will continually change based on the needs of the user - but must be within the confines of the Account List Table.
What I have tried is here and enter link description here. I keep getting result of #Value, or N/A. I can't figure out what I am doing wrong. I know that I need to nest the SUMIFS withing VLookUp, but I am not sure as to why it won't work.
I'm providing you with two possible solutions.
1) The first one uses the SUMPRODUCT function. You may not have seen this kind of notation before.
When ranges are multiplied by each other like so (B3:B8=G3)*(C3:C8=G4) they are actually turned into boolean arguments. If you highlighted this part of the code and pressed F9 it would look like this: {0;0;0;0;1;0;0}. This is an array where TRUE for both criteria meet. So our Branch is "A" and our Carrier is "F". In the rest of the cases either or both are false resulting in zeroes.
Now if you multiply this array by the range with account numbers, obviously the only number remaining will be the one multiplied by 1 and so you have the answer however keep in mind that as you are multiplying if the account is not a number the function will fail!
2) This is why we have a second method using =INDEX() and =MATCH() functions.
To overly simplify this - the INDEX function grabs contents from an array at a specified position (row and column), while the MATCH function gets the position of an item in an array.
The idea with using ranges as multiple criteria is the same as in the first example, however this time when we get our array of zeroes and ones {0;0;0;0;1;0;0} we use the match function to find at which position our criteria cross (as seen on the screenshot it's the 5th position, as it's in the 5th row of the entire column D, the match function searches the {0;0;0;0;1;0;0} array for a 1 and returns its position in the array) and so this is our ROW.
Knowing the position of the contents we searched for we use the INDEX function to grab the contents of the cell in that position so =INDEX(D2:D8,MATCH(1, INDEX((B2:B8=G3)*(C2:C8=G4),0),0)) is actually =INDEX(D2:D8, 5) meaning that the INDEX function grabs contents of the 5th row from the range D2:D8 which is cell D6.
The green boxes are just there to show the instance where both of our criteria are met (cross).
Please try this formula.
=INDEX(Table1[Account],SUMPRODUCT((Table1[Branch]=F$3)*(Table1[Carrier]=F$4)*ROW(Table1[Account]))-1)
Note that you may have to adjust the final -1. This is because the indexed table starts in row #2 and the SUMPRODUCT function returns a sheet row number. If your table would start in a different row the difference between the sheet row and table row would be larger. It must be adjusted here. Or you might work with sheet references (named ranges) and require no adjustment at all.

Seeking help to excel in Excel

This pictures shows my table and formula's yield
I have used following formula to extract result from a table.
Its working perfectly fine but I am hoping to level up my understanding of Excel formulas.
The trouble is that I use IF in Excel way to often.
what I wanted to know is if its possible to use a different approach, something that can work similar to if but is perhaps more sophisticated.
=IF(OR(J2="08L",J2="08R"),IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$34,0)),"LAM",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$35:$E$35,0)),"West",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$36:$G$36,0)),"East",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$37,0)),"SFD",NA())))),0)
I very much appreciate any help.
Now that there is an example, I think this is a good question. You've recognised that your formula is fairly messy and also can't be easily expanded if there are more routes.
The problem is that Excel is very good for searching for a value in a single row or column, but not as good for searching for a value in a block of data.
You can simplify this problem by creating an additional column that has each entire route in a single cell. You can do this just by concatenating values. In your example, use column H:
=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2
This will create a string with the entire route in a single cell. Spaces are added in between each part of the route to make sure you don't accidentally create a sequences of letters that matches part of another route. It doesn't matter if there are blank cells, there will just be some extra spaces at the end which doesn't matter. Fill this down the column to get the entire path for each route in a single cell.
Then, you can create a formula that tries to find the 3 letters anywhere in any of the full routes.
=INDEX($A$2:$A$5,MATCH("*"&left(I2,3)&"*",$H$2:$H$5,0))
This formula is basically a deconstructed vlookup. It determines where the 3 characters can be found in column H, then gives back the corresponding value from column A.
The MATCH function tries to find the left 3 characters of I2 in column H. The MATCH function normally tries to find a complete exact match (with the last parameter being equal to 0), but we can just add wildcards to the search value. The MATCH function then returns the index of the range where it was found. I.e., if it was found in the 2nd cell of the range H2:H5, it returns the number 2.
The INDEX function then just gets a value from a range based on an index. In this case, it will get the 2nd value from range A2:A5.

Using the 'Match' function in Excel to return a cell address

I have a list of numbers in a table that I would like to search for and bring back the cell reference of where that number resides. For example the data looks like:
A B C D
1 1 2 3 4
ok it doesn't come out very well as the first one is the row number and then each number below sits under each letter, so C1 would contain '3'....
If I wanted to return the reference number of C1 in a cell I am using the formula of =CELL("address",MATCH(AU14,C1:AG1)) but this just errors. I have tried to put an Index in there too, but I believe that index only works vertically so this bring back a #N/A result.
Can anyone assist as I've wasted too much time on this already! :)
You are indeed missing an INDEX. And INDEX works vertically, horizontally, or both depending on how it's called.
Here is a formula that works for the ranges in the pictures. Should be easy to modify.
Formula in C5
=CELL("address",INDEX(B2:F2,MATCH(C4,B2:F2,0)))
formula
results
To make CELL work you need a cell reference, e.g.
CELL("address",C1)
The trouble is that MATCH just gives you a number, not a cell reference.
Probably the easiest way is to use the ADDRESS function, so a first try might be
=ADDRESS(1,MATCH(AU14,C1:AG1,0)+2)
That would give you the right answer if AU14 contained 3, but isn't considered to be very good because it wouldn't update if you deleted/inserted rows or columns.
A better one would be
=ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1)
Then you might want to put in some error handling for the case where it's not found
=IFERROR(ADDRESS(ROW(C1),MATCH(AU14,C1:AG1,0)+COLUMN(C1)-1),"Not found")

I need help consolidating a list of supplier names that change periodically?

I have a spreadsheet that I am using as a questionnaire.
One of the questions is Who are your wheel suppliers (mark all that apply)? and there are 6 check boxes in column C to select 5 different wheel suppliers and an Other option. I have these check boxes linked to return whatever suppliers name is selected in the cell adjacent to the cell the check box is in in column I.
So depending on what wheel suppliers the customer selects there could be anywhere from 1-6 different suppliers selected. So once the customer has selected the wheel suppliers whatever suppliers are selected will show up in the correct cell in range I45:50.
What I am having a problem with is that I need these to pull into a data tab into one cell. I am having a problem coming up with a formula to put all the suppliers together as a list in one cell with commas separating each. Remember, it could be 1 supplier, could be 3, could be 6.
Any advice is much appreciated. I have tried using If formulas and Concatenate but I can't seem to figure out how to get it to work like I want it to.
=CONCATENATE(Questionnaire!I45," ",Questionnaire!I46," ",Questionnaire!I47," ",Questionnaire!I48," ",Questionnaire!I49," ",Questionnaire!I50)
That is the best I've come up with but the problem with it is if the first supplier isn't selected then it will enter that space anyways and if the first supplier and the last supplier are selected it will have all those spaces in between.
Another method, this one using helper cells.
Say you have the data in A1:A6. In B1, input this formula: =IF(LEN(A1)>0,A1&",",""). Drag down to B5.
In B6, slight variation: =IF(LEN(A6)>0,A6,",""").
In C1: =CONCATENATE(B1,B2,B3,B4,B5,B6).
What happens is the cells in the B column checks if their respective values in the A column are not blanks. If not, they will append , to it. Otherwise, they will return blanks (not spaces). The only variation is B6--since it's the end of the list, there's no , appended to it.
It's only a matter of concatenating them at this point. Removing any of the values in A, maybe by unchecking their checkbox, will reflect the change in C1 properly.
Let us know if this helps.
EDIT:
To accommodate your formula, change your CONCATENATE formula to something like below:
=LEFT(CONCATENATE(...),LEN(CONCATENATE(...)-1)
What is does is it removes the rightmost character by getting, from the left, all the characters up until one less than the length of the result. Obviously, fill in the ... with the ranges you want to concatenate.
Let us know if this is what you need.
FURTHER EDIT:
=LEFT(CONCATENATE(Questionnaire!F45,Questionnaire!F46,Questionnaire!F47,Questionnaire‌​!F48,Questionnaire!F49,Questionnaire!F50),LEN(CONCATENATE(Questionnaire!F45,Questionnaire!F46,Questionnaire!F47,Questionnaire‌​!F48,Questionnaire!F49,Questionnaire!F50))-1)
Looks ugly, right? But does the job. Better if you use a named range, though, like below:
Now it's much shorter. Error on my end is because I don't have Questionnaire sheet, obviously.
If J44 is blank and you are prepared to add something like =IF(ISBLANK(I45),J44,J44&I45&", ") in J45 (copied down) then perhaps:
=SUBSTITUTE(LEFT(wheelC,LEN(wheelC)-2),0,"")
might suit, where wheelC is a named range of workbook scope for Questionnaire!J50.

Resources