I've used VLOOKUP plenty of times, but this has really stumped me. I have a VBA code that copies data from one workbook to another and then I'm trying to perform the VLOOKUP on the data that I've copied.
Here's an example of how the data I've copied is layed out in Sheet2:
5009 | Materials | Store Items
The table that has been copied is given the name "AutoList" for the range of the table (Theres a lot more than this obviously)
The table I'm trying to use the VLOOKUP on looks like this:
[VLOOKUP] | Materials | Z | X | C | V
The formula I am using is:
=VLOOKUP("Materials",AutoList,1,0)
I can't for the life of me figure out why I am getting #N/A as the result. If I remove the 0 on the end (for the logic), I end up with the last number in the AutoList table for every result as it's only doing a partial match.
Any help would be appreciated!
Is the "lookup_value" in the first column of your "table_array"...?
According to Excel's help file vlookup looks, "for a value in the leftmost column of a table." Does AutoList define your range with "Materials" in the first column? If so, then shouldn't the result of your vlookup formula return "Materials"?
Related
If the answer was already provided, please feel free to post the link, but I did not see one.
This is a real estate example. I have a table of a lot of properties and information. One of the fields is "Occupancy." I am trying to use the AVERAGE OFFSET functions combined with CELL and INDEX/MATCH to calculate the average Occupancy of the top 5 and top 10 buildings in this table. To accomplish this, I wanted to create a "Summary Table" below the Property table to list the averages.
Specifically:
For OFFSET, in the "Reference" section, I want to look up "Occupancy" in my summary cell, use INDEX MATCH to find "Occupancy" in the table, and then;
I want the Cell Reference returned AS A VALUE and then move one row down and then highlight the top 5.
Most importantly, I want everything cell referenced without hardcoding or navigating the table to highlight the cell reference. I am not sure if this is possible, but after pouring through a bunch of articles, I am having trouble finding a solution.
To make things simple, let's pull out all the columns I had in the original table and go off the below. Assume all the data types are in the proper format:
**COLUMN A** **COLUMN B**
ROW 1 | Properties | Occupancy |
ROW 2 | Property A | 58% |
ROW 3 | Property B | 56% |
ROW 4 | Property C | 77% |
ROW 5 | Property D | 85% |
ROW 6 | Property E | 92% |
ROW 7
ROW 8 |Top 5 | | 'NOTE: I used a custom formula to format:
"Top "#. Please do not think this is text.
ROW 10|Occupancy | **CODE HERE**| 'Format is "General"
ROW 11| | |
ROW 12| | |
Here's how I initially coded it in B10:
'=AVERAGE(OFFSET(CELL("address",INDEX($A$1:$B$1,MATCH(A10,$A$1:$B$1,0))),1,0,5,1))
I am getting "there is a problem with your formula" since I am guessing it is due to the cell returning text in lieu of the cell reference as a value. So I error checked myself and stripped out the AVERAGE, OFFSET and put this is B11:
'=CELL("address",INDEX($A$1:$B$1,MATCH(A10,$A$1:$B$1,0)))
I know I get $B$1, so I then put $B$1 to replace the CELL function within B10 to see if my average offset is wrong:
=AVERAGE(OFFSET($B$1,1,0,5,1))
I now get the right solution since I went and hardcoded the reference, which does not solve the issue.
If I use INDIRECT and then CELL in B12:
'=INDIRECT(CELL("address",INDEX($A$1:$B$1,MATCH(A10,$A$1:$B$1,0))))
I then get the title "Occupancy" and not the cell reference.
Obviously, I am aware of the fact that the CELL function will return text and not a value. I can't use INDIRECT because when I do, INDIRECT will just display the title of the column in text and not return the cell reference as a value. ADDRESS is not useful because you have to hardcode and the goal is to have zero hardcodes.
How can I code finding the cell reference of specific text in a table without actually going to the table to cell reference when I am building out my OFFSET function?
As you can see, I went through a variety of ways to dissect the problem and I would appreciate anyone's help to come to a solution. Thanks in advance.
I need to return in a cell all the cell values where the cell next to it contains a value range.
For example, if I have a table like this:
|Name |Evaluation
|------|------
| John | 3
| Sue | 4
| Jim | 2
| Andy | 6
| Tim | 1
| Bruce| 4
I'm looking for a formula to have all the names whose evaluation is >= 4, so, if applied to the table it should give as output in a single cell:
Sue
Andy
Bruce
I've already tried VLOOKUP, INDEX, MATCH and FIND functions but they all return a single value (the first cell that match) and not all of them.
If possible, I'm looking for an Excel Formula and not for VBA (this way I can share it easily with my working group that, as myself, is not very proficient in VBA).
Thank you very much!
=IF(B1>=4,A1,"") write the command in c1 column and drag the C1 column to the end of the column till the end name
(assuming you write first name in A1 column and Evaluation in B1 )
I've solved the issue by using (partially) the solution posted by dhS and a support table.
I've created the support table of the same height of the original one. This table goes from F1 till F120 (the end of the original table).
In the first cell i've used the formula
=IF(B1>=4;$B1;"")
In all the subsequent cells (from the second to the final one)
=IF(B2>=4;IF(F1="";B2;F1&CHAR(10)&B2);F1)
This way, in the last cell there will be all the names separated by a return (CHAR(10)).
To anyone who want to use this solution, remember to enable the Wrap Text option on the cell, otherwise you won't be able to visualize the returns.
Thanks to everybody for the help you gave me.
I have spent the day trying to learn vba code and searching other questions for the same example but have been unable to crack this so help would be greatly appreciated.
I have worked out how to do it in vlookup but only to a single row.
This code from kutools is the closest i could find and almost does what i need but is only reading single digits in my range (which goes up to 700) so the value i return is multiples of the value string. This would need to be modified to only search and replace the specific value. http://www.extendoffice.com/documents/excel/1873-excel-find-and-replace-multiple-values-at-once.html
I have 3 columns: A has a random list of numbers, many repeating; B has a list of reference numbers which correlate to a place name in C.
A | B | C
1 | 1 | Melbourne
1 | 2 | Adelaide
1 | 3 | Sydney
2 | 7 | Auckland
2 | |
3 | |
7 | |
The code should result in the number in column A being replaced by a place name from column C by first finding the matching number in column B. Note: There are less rows in columns B&C than there are in column A.
There are thousands so i need a code to do this.
Thanks in advance.
Well first off I'd place the VLOOKUP data into a new column so to preserve your original data set, but here's the code that you should be looking for:
=VLOOKUP(A1,$B$1:$C$4,2,FALSE)
Here's the syntax of a VLOOKUP:
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Now for each part. The lookup_value is what you're using as a reference to search for, this will be your information for columb A. The table_array is a static reference of where to look for this value, and then the resulting values you want to display, so in your sheet you'll make this all of columb B and C. The col_index_num represents the index of the table_array you chose previously, so since the name of the cities is in the second column of this table, we put 2. range_lookup is whether or not you want an exact match. We do, so we set it to true. And then you can just replicate this value down a column to have the results for everyone.
That should be exactly what you're looking for. I even created a test sheet to try it out. In the future I suggest posting the code you've already tried.
I have a basic financial spreadsheet that I am trying to make even nicer. I have a table that looks like this:
| Description | Category | Amount
| 2341234 Chick-fil-a | Eating Out | 5.89
| 11234 Redbox/Georgetown | Entertainment | 1.21
And another table that looks like this:
| Name | Category |
| Chick-fil-a | Eating out |
| Redbox | Entertainment |
I want to find the strings from the first column of the second table in the first column of the first table and automaically populate the second column of the first table. I am pretty sure I can find the position of the string by doing a {=find(2ndSheet!A:A,1stSheetA:A)} or something of the like, but I have no idea how to populate another cell based off of that.
Does it have to be a macro?
This is a bit ugly but seems to work. It handles the situation where your description may not necessarily match the lookup table (for instance, with Redbox | Redbox/Georgetown). Replace the [Lookup_Table] with the absolute range of your lookup table, and enter as an array formula (Control+Shift+Enter):
=INDEX([Lookup_Table],MATCH(TRUE,NOT(ISERR((FIND([Lookup_Table],A2)))),0),2)
As for what it's doing:
=INDEX(
[Lookup_Table],
MATCH(
TRUE,
NOT(ISERR((FIND([Lookup_Table],A2)))),
0),
2)
It's using an INDEX formula with the [Lookup_Table] as the base range. For the row to match, it looks for instances where running the FIND formula using the current cell does not cause an error. So in the case of Redbox, you'd get an array like {#VALUE!, 7}. You then set the values to TRUE/FALSE based on whether they are errors, and then flip them so that non-errors are True. You then match the TRUE condition against that array, and a hit will return the row number in your lookup table. You then use that row number and column 2 to find the corresponding value.
Again, that is not a pretty one (and there is probably a better way to handle all of your cases), but it seems to work in my extremely exhaustive test of three rows :)
Assuming that your first table is starts in column A, substituting this formula starting in B2 should find the value for you.
=VLOOKUP(RIGHT(A2,LEN(A2)-FIND(" ",A2,1)),[Range of Helper Table],2,FALSE)
You'll need to substitute [Range of Helper Table] with the actual range. Make sure you use absolute references using $, for example: 2ndSheet!A$2:B$20. so that you can copy and paste.
Hi All You Amazing People
Update
You know what, I should let you know that I am actually trying to do this with numbers and not alphabets. For instance, I have a field with value like 225566 and I am trying to pick out fields which have 55 in them. It is only now I realize this might make a huge difference
ColumnA | ColumnB |
225566 | 2
125589 | 3
95543 | 2
(Below is what I had asked first and later realized I wasn't asking the right question.)
*Lets say I have a table as
ColumnA | ColumnB |
AABBC | 2
AADDC | 3
ZZBBC | 2
Now how could I get a SUMIF for those rows where Column A has a field with BB in it? Assume that there are hundreds of rows. I realize that I have to borrow something conceptually from the way text to column is done. But I wonder if anyone would know how I could do this. Thanks a lot.*
Since you're trying to do this on numbers, you'll need to use an array formula.
If your test values are in A3:A5 and your values to sum are in B3:B5, this will work:
=SUM( IF(ISERROR(FIND("55", TEXT(A3:A5,"#"))), 0, 1) * B3:B5 )
When entering an array formula, use Ctrl-Shift-Enter rather than just hitting Enter.
This sums the product of the sum value and a 0 or 1 from the IF() statement, which tests whether or not each test value, after being converted to text, contains a "55".
I think you will need an matrix/array formular to do this:
{=SUM(IF(ISERROR(FINDEN("55";A2:A4;1));0;1))}
The weird brakets {} indicate it is an matrix formular you get them by pressing SHIFT+CTRL+RETURN instead of Return when editing the formula.
This formula will cycle through the range A2:A4, check if it finds "55" inside and if so add 1 to the sum.
Google array/matrix formulas as they are not self explanatory.
Best
Jan
In Excel 2003 and 2007 (and possibly earlier versions, I cannot test), you can use * as a wildcard character in the match. For example, with your sample data set C1 to
=SUMIF(A1:A3,"*BB*",B1:B3)
and you should see the value 4.
Create a 3rd column (ColumnC) and put this formula in it:
=Text(A2,0)
Drag that column down to complete your column. This will format the value as text. Next, use SUMIF as DocMax explained, except with different columns:
=SUMIF(C1:C3,"*BB*",B1:B3)
The reason you do this is because you need to be reading a Text value, not a Number value when using the *BB* comparison of SUMIF. Great question.