I'd like to search an element in a column and then use this element in a vlookup formula. My column contains either the same number (i.e : 2300) or nothing (""), but I have 26 different possible number (each number = a company).
I'd like to avoid VBA if possible
Example:
File 1.xlsx, COL A:
""
"2300"
"2300"
""
"2300"
"2300"
...
File 2.xlsx, COL A:
""
"1200"
""
"1200"
"1200"
"1200"
...
So if I'm the File 1.xlsx, I'd like to do the following : "If find something different than "", then print the number".
Hope I'm being clear. Thanks for your help in advance!
Jean
You can't use a vlookup on this kind of data. The value you're looking for must be in column sorted in alphabetical order, then from that, you can retrieve the value present in a cell present on the same line.
If you only want to test if the cell in empty, you could do simply this
=IF(<your cell>="";<you other cell>;"")
Be careful of relative and absolute coordinates.
This formula will return the first non-blank value that doesn't match 2300 in the range A1:A10. Update the range (in all 3 places) as required, and replace 2300 when searching for different values.
=INDEX($A$1:$A$10,MATCH(1,($A$1:$A$10<>"")*($A$1:$A$10<>2300),0))
Note this is an array entered formula. To enter it correctly, you need to double click into a cell so that you're in edit mode, paste the formula then confirm it by pressing CTRL+SHIFT+ENTER
Related
I have the following formula to make a unique list from column plant in table 15:
{=IFERROR(INDEX(Tabel15[Plant];MATCH(0;COUNTIF(Analyses!$Q$2:$Q2;Tabel15[Plant]);0));"")}
This formula is working, but when there is just 1 value in column plant the formula gives a value of 0. This is wrong because it should return the value.
Does anyone know how I can adapt this formula to make it work?
I wanted to change it to this:
{=IF(COUNTA(Tabel15[plant])>0;INDEX(Tabel15[Plant];MATCH(0;COUNTIF(Analyses!$Q$2:$Q2;Tabel15[Plant]);0));Kopie - datablad$G$2)}
But it doesn't work either.
Good mock example. Try and see if this works:
The formula counts the unique cells against another list. The unique list expects to take the first row, no matter what. It also expects you to have more than one value in your duplicate list. If it doesn't you can't compare since it expect duplicates and it throws an error, #N/A. This is mask as blank cell since it's wrapped in IFERROR:
"Unique formula" = IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF($Q$1:Q2,Tabel15[Plant]), 0)),"")
To solve this we check how many values it exist in our duplicate list:
=IF(COUNTA(Tabel15[Plant])>1,... "Unique formula" ... ,Tabel15[Plant]) //***//
This will give us this result.
Then you probably don't want duplicates...
So we need to check if previous rows contain any of the values the formula would return.
The VLOOKUP formula do that for us, and as lookup value we use the formula above //***// and lookup range will be our current column: $Q$1:Q2. NOTICE this is a dynamic range so Q2 is relative reference (no $).
=IF(ISERROR(VLOOKUP(IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF($Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),$Q$1:Q2,1,FALSE))
So the Final result we need to apply is this in Cell Q3:
=IF(ISERROR(VLOOKUP(IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),Analyses!$Q$1:Q2,1,FALSE)),IF(COUNTA(Tabel15[Plant])>1,IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$1:Q2,Tabel15[Plant]), 0)),""),Tabel15[Plant]),"")
The macro error can be ignored by:
If Not IsError(Sheets("Hulpblad").Range("B6").Value) Then
t = Sheets("Hulpblad").Range("B6").Value
'Code...
End If
there is no problem in your formula, it is just telling that there are blanks in the range, 0 means blank. the formula is treating the blank as a value and also considering it in the unique value calculations.
If you want to remove 0 you can just insert an if over your formula to remove it. like
=if(formula = 0, "", formula)
or in orignal form
=IF( (IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$2:$Q2,Tabel15[Plant]),0)),""))=0,"",IFERROR(INDEX(Tabel15[Plant],MATCH(0,COUNTIF(Analyses!$Q$2:$Q2,Tabel15[Plant]),0)),""))
or go in the cell formatting and change the format to display 0 as a dash.
sometimes blank is also used as error checking, you can apply such formulae as well to check how many are blank, maybe that would someday be used to check any data entry problems.
I need to find the starting cell number and the ending cell number of a specific value. For example if I have this excel sheet:
Here, I when I search for “10:” in the formula, I should get:
A1:A5
For example there’s this formula =COUNTIF(range, text) using this formula I can count the number of times that certain text is being repeated. Now I need a formula where when I enter a text, it should tell me the starting cell number and the ending cell number.
I hope I’m clear. Is this possible?
You need =iferror("A"&MATCH("10*",A:A,0) & ":A"&MATCH("10*",A:A),"") if you were searching for things that begin with 10. You can change 10 to a cell reference so long as you & "*" onto that.
The first MATCH piece gives the first matching row number in the range (which since I am looking at the whole column is the row number) and the second gives the last that is <= (in our case = because we found a first that is =). If we find nothing, the iferror handles that and returns blank for the whole thing.
The above is assuming column A is formatted as text (and sorted -- it is not meant to handle if the matching entries were in a1:a3 and then there was another in A7).
On tab 1, I have data down column B that contains string values like this:
\\ABC\VOL1\DATA\Dan\Personal Folders
\\ABC\VOL1\DATA\Mike\My Stuff\Docs\Support
\\ABC\VOL1\DATA\Mike\My Stuff\Photos
\\ABC\VOL1\DATA\Bob\Plans
On tab 2, I have data down column C that I want to use as a lookup table like this:
\\ABC\VOL1\DATA\Adam
\\ABC\VOL1\DATA\Steve
\\ABC\VOL1\DATA\Mike
\\ABC\VOL1\DATA\Ronnie
I need a formula I can put on tab 1 down column C to see if any part of each text string from tab 1, column B matches any complete text string from tab 2, column C. So for example, I would place this formula to show Yes or No like this:
Column B......................................................................Column C
\\ABC\VOL1\DATA\Dan\Personal Folders....................No
\\ABC\VOL1\DATA\Mike\My Stuff\Docs\Support..........Yes
\\ABC\VOL1\DATA\Mike\My Stuff\Photos.....................Yes
\\ABC\VOL1\DATA\Bob\Plans.......................................No
I have tried VLOOKUP, INDEX/MATCH, ISNUMBER/SEARCH, and COUNTIF as an array with wildcards, but I just cannot seem to figure it out. Currently, with COUNTIF as array, I have this:
=COUNTIF(B2,"*" & 'Tab 2'!$C$2:$C$1000 & "*")
This is the start to return the array results, but the results aren't as I would expect as I get "0" when I should get "1" for certain rows.
If anyone can help me out with a formula (not VBA) using any of the functions mentioned above or any others, I would greatly appreciate it. Thanks.
use this array formula:
=IF(COUNT(SEARCH('Tab 2'!$C$2:INDEX('Tab 2'!$C:$C,MATCH("zzz",'Tab 2'!$C:$C)),B2)),"Yes","No")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
This will search the cell for any of your criteria and return the number of matches if there is a match (which unless you have duplicates in the criteria it will be a 1).
Enter as array.
{=COUNT(SEARCH($C$1:$C$4,B1))}
Hi all,
I have this excel where by I need to find the location of the item if they are found in column B.
So In my F column, I tried to write ifelse formula which didnt work.which is
=IF(D2="NULL","NONE",C((D2))).
My idea is if D2 is not null, use the value in D column to find the location in C column. In this example, fish no 4, so it is found, my F column should show the value "C" using the value shown in D column and use it as Row no in C column
I hope you guys get the idea and help me out a newbie in excel. Thanks in advance
=vlookup($D2,$A$2:$C$6,3,0)
you can use that in column F. Place that formula in F2 and copy down.
you could technically use it in column E as well, but you would need to change the 3 to a 2.
you did not say what you wanted to do if the D value was "Null" so I am going to take a stab at the dark and wrap you lookup formula in an if statement that will deal with "Null" or empty cells
=IF(OR($D2="NULL",$D2=""),"",VLOOKUP($D2,$A$2:$C$6,3,0))
That is the alternative formula to place in F2 and copy down.
Use the formula:
=IF(D2<>"NULL",VLOOKUP(D2,A2:C6,3,FALSE),"Value is NULL")
Here is the working example:
Put formula in cell F2 and drag it down.
[edit]to pull proper location column, not just the row #[/edit]
Seems like a job for MATCH+OFFSET
Try this formula in cell F2:
=OFFSET($C$1, MATCH(E2,B:B,0)-1, 0, 1, 1)
Match is used to locate the value in the first argument (ie E2) within the range specified in 2nd argument (ie B:B). I use B:B but you could also use range B2:B30 or whatever more specific range you want. (I prefer the more generic B:B, though :) )
Third paramter "0" just indicates "Exact match".
This function will retun "#N/A" if nothing found.
OFFSET takes the result from MATCH to pick out the Location you want. The first parameter in OFFSET is the rows below (or above if negative) from the base row (in this case $C$1). the next is the column: 0 since we're in the column we want to be in. The last two are the size of the range: 1,1 is a 1x1 cell, so just 1 cell. If we did ...,2,3), that would be 2 rows high and 3 columns wide - or a 6 cell range. We're just after 1 cell here.
I've always preferred MATCH + OFFSET to other options, I just found they held up more robustly to changes in a sheet (ie new rows/columns added). So it's mostly personaly preference over VLOOKUP and INDEX. I honestly have never compared their actual performance, however, I've never had any issues with MATCH+OFFSET running slowly :)
I need to take all the text in one cell and find it (even partially find it) in another column of cells. If there is a match it needs to return the value of another cell in the same row as the cell found.
For example: In Sheet 1 Cell A1 has the text "John Smith".
Now in Sheet 2: Column D I need to find any cells in the column that have "John Smith" (chances are there will be only one "John Smith" so no need to worry about returning multiple values) and whatever cell in Column D Sheet2 contains "John Smith" needs to return the value that is in Columna A of sheet 2 of that same ROW.
I dont know how complicated this sounds but this process takes me 2 to 3 hours to do manually and just wanted to know if there is a way to do it faster through formulas.
Thanks in advance! :)
You may wish to utilise the scripting function of MS Excel, or even write an entirely separate program if this is a regular task. I'm going to give you a pseudo-code example in C# to show you the concept.
Now, we need to create a placeholder for the cell that contain's John's name:
string nameCell (get; set;)
And one for the data to be returned:
string returnValue (get; set;)
And now, to get things running.
First of all, we want to define the row that we're working with. We could also use a foreach loop to run through every single row: foreach Row row in workBook. But that's a little complicated, since I'm assuming you're new to programming.
So, we'll just use the one row for now. Let's call it workingRow:
Row workingRow = workBook.row(1)
See that number at the end of workbook.row? That tells us to look at row one.
Now, to look at the cell and see what it contains:
if (workingRow.nameCell = "John Smith")
{
returnValue = workingRow.valueCell.ToString()
}
else
{
returnValue = ""
}
This small piece of code will tell the application to return the value in string format, whilst returning an empty string if "John Smith" is not found.
This should be fairly easy, perhaps an hour's work, to transform into workable material, whether you use a script inside Excel or build a completely separate program. Good luck!
Exact match: =INDEX(Sheet2!$A:$A,MATCH(A1,Sheet2!$D:$D,0))
Partial match: =INDEX(Sheet2!$A:$A,MATCH("*"&A1&"*",Sheet2!$D:$D,0))
Starts-with match: =INDEX(Sheet2!$A:$A,MATCH(A1&"*",Sheet2!$D:$D,0))
MATCH
finds the value of A1 ("John Smith") in column D, returns its position
0 indicates an exact match looking at each value and allowing wildcards, as opposed to a faster sorted search (a sorted search requires sorted data and returns a neighboring result when it can't find the one you want)
"*" is a wildcard matching any text of any (even 0) length
INDEX
Returns the value in column A at the position returned by MATCH
use MATCH() function to find out which row in column D on Sheet 2 "John smith" appears. Make sure your column D is ordered alphabetically.
Use OFFSET() with cell A1 on Sheet 2 as reference (or the top DATA (not heading) cell of the column from which you want to display the data) and the result of the MATCH() function above as the "rows" argument
If you are struggling to achieve desired result, post what you have, and we can help further.