compare a part of a cell with the another column - excel

I need a help with excell tables. I need to compare a only part of a cell with another column actually I need to see if the data exists.
The cell part would be the first 4 letters left(s2;4) with b1:b1000
I have tried with:
=IF(AND(LEFT($B$1:$B$1000;4)=LEFT(S2;4));"match";"no match")
but it doesnt seem to search thorough the whole column $B$1:$B$1000 but it compares s2 with b2
Thanks

If you are just trying to see if the string exists in the search list (presumably B1-1000) - this should work for you.
=IF(COUNTIF($B$1:$B$1000,"*"&LEFT(S2,4)&"*")>0,"Match","No Match")

Related

Test whether a value in a cell matches another value in an array, and do an action if a match is found

I am trying to create a formula that will look at a cell and test the value in that cell against an array or multiple arrays of cells, and if a match is found, take another action like calculate a mathematical formula.
Really the action taken afterwards is not the issue, just used as a reference of what I ultimately intend to do with the formula. The biggest hurdle I am having is the first part of the formula where I need to test values.
I need to test the employee ID's in column W against the same employee ID's located in the "doors" columns and see if there is a match, and if there is, do another action.
Formulas I have tried, though I really don't know what I should be doing here:
{=IF(W5=T4:T7,"true")}
{=IF(OR(F4:F7,H4:H7,J4:J7,L4:L7,N4:N7,P4:P7,R4:R7,T4:T7)=W6,"True")}
Any help would be appreciated. Please let me know if I need to elaborate.
Use MATCH for one column:
=IF(ISNUMBER(MATCH(W6,$T$4:$T$7)),X6/5000*1000000,0)
For multiple columns:
=IF(ISNUMBER(AGGREGATE(15,7,ROW($B$4$:$T$7)/($B$4$:$T$7=W6),1)),X6/5000*1000000,0)

Excel Formula - Compare two tables (If match is found in name, calculate difference in charges.)

I am trying to figure out a formula to find and calculate the difference in charges from two tables which has matching facility names. If facility name does not have a match then leave blank or if NA in calculation cell.
Looking at your screenshot I'm assuming the first row after the header is on row 7. You can try to paste this to cell J7:
=IFNA(VLOOKUP(CONCATENATE(RIGHT(F7,2)," - ", G7),B:D,2,FALSE)-H7,"")
What it does is using vlookup function to get the data from the other table. But since they don't have the common value, I use CONCATENATE(RIGHT(F7,2)," - ", G7) to generate common value assuming column B has a unique value.
If I understand your question correctly, this is what you are trying to do:
This is the formula to enter from cell J6 and you can drag it to K6 as well:
=IFERROR(INDEX(C$6:C$12,MATCH("*"&$G6&"*",$B$6:$B$12,0))-H6,"")
Basically, the trick is to use wildcard * to perform this search. Try and let me know if this is what you are looking for.

How to tell if a cell exists on another Google Sheet

I have 12 sheets in one Google Sheets document labeled for each month (January - December). On each sheet column A contains a project number, e.g. "6091".
I'm trying to find a function that will check all of the other sheets to see if there are duplicate cells in the "project number" column of other sheets.
So: "Do any of the cells in column A, match any of the cells in column A on other sheets".
Is there a quick way to do this?
The formula =arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0))) checks each value in A2:A of the present sheet for being in A2:A of AnotherSheet. If it's there, it returns the position in AnotherSheet, otherwise the output is empty (the error #N/A is suppressed by iferror).
You can use the above for each of the sheets separately. Alternatively, if you are not interested in the positions and just want to know which entries from A2:A are found elsewhere, then add the results for each sheet:
=arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0)) + iferror(match(A2:A, ThirdSheet!A2:A, 0)))
The output is 0 is there is no match, and a nonzero number if there is.
You may try using this to find the number of duplicates:
=counta('JAN'!A:A,'FEB'!A:A)-countA(unique({'JAN'!A:A;'FEB'!A:A})
Where A:A is your column for the data you want to check and the respective files.
This formula counts the total number of data you have, minus the unique data, therefore giving you the total number of duplicates in your dataset.
This formula gives you an overview of the total number of duplicates, however, it doesn't show which cell is a duplicate.
Alternatively, you can add a checker column and input the following formula to check if that specific cell is a duplicate.
=match(cell to check,{range 1;range 2;...range 12})
Alternatively, you may use this formula to find the exact duplicates between the ranges, however this formula does not search within the range itself for duplicates.
=arrayformula(filter(range to check,(countif(arrayformula({Range 1;range 2}),{range to check}))>1))
Personally I think that the last option would be the best as it gives you the exact data to correct.
I am still new to this so hope this helps:)
This formula should work for numerical values:
=COUNT(QUERY({March!A:A;April!A:A},"where Col1="&A2))
If you are searching for text values it would be
=COUNTA(QUERY({March!A:A;April!A:A},"where Col1='"&A2&"'"))
Unfortunately the QUERY function does not work within an arrayformula so you would need to copy the formula down the column. You can add in extra sheets into the { } array as required, separated by a semi-colon
Edit: actually, borrowing from #sandwich, this version should work without the need to copy the formula down the column:
=arrayformula(iferror(match(A2:A,{March!A:A;April!A:A},0)))

find matching values in 2 different columns in 2 different excel file

Hi new to vba in excel 2007
Here is the scenario I want to write a macro where a value in column A from abc.xls is in column c from .xyz.xls. If someone can help me out with this logic and can easily finish the rest. Thank you for your time.
Welcome to SO. Going on what Tim said in his comment vlookup() is an easy way to find a value in another sheet. In your case the function would look something like this:
vlookup([abc.xls]Sheet1!A1, [xyz.xls]Sheet1!C:C, 1, False)
The first part is the value to look up, the second part is the table to look for the value in (in our case only the one row), the third part is which column of the table to return the value from, and the third part tells it to find an exact match. So this function will look for the value in A1 of abc.xls in column C of xyz.xls and return that value if it finds it.
If you instead want the row where the value was found use the match function.
match([abc.xls]Sheet1!A1, [xyz.xls]Sheet1!C:C, 0)
This will do the same thing as vlookup but return the row where it found the match instead.
Note that you don't have to type these formulas in directly. If you navigate to a new workbook and select the cell it should generate the reference just as if you had selected one from the current sheet.

Concatenating cells in Excel ignoring blank cells

I've searched through the site but can't seem to see anything that fits my problem.
I have 7 columns
User ID
Session1
session2
session3
session4
session5
session6
Within the sessions 1-6, there will be a P or A to represent whether the user was "present" or "Absent".
Based on this master data, I have created a further 6 columns to the right of this will the same headings and input IF statements to say =IF(B2="P","",B$1) so that it will show the Session ID if the user was absent from that session.
I then need to have all the users absent sessions within one column and that needs to be sepearated by commas.
What I can't work out is how to get this without have duplicate commas where the cells are blank.
Any ideas?
Thanks
James
Pick up the StringConcat UDF given at the link C Pearson Concatenation page. Copy the code starting from Function StringConcat(Sep As String, ParamArray Args()) As Variant upto the end, and paste it in a general module in VBA. If you don't know how to do this, refer this link which explains it all.
This UDF will ignore blanks, and concatenate any given range with a separator/delimiter of your choice.
Your solution then simply becomes
=StringConcat(", ",H2:M2)
Let me know if something isn't clear.
Alternate Solution :
Alternatively, modify your formulae as follows.
In cell H2, instead of =IF(B2="P","",B$1) , enter the following formula
=IF(B2="A",B$1&", ","")
Copy this formula upto M2, and down as many rows as you want.
Now, in cell N2, put the following formula:
=IF(LEN(H2&I2&J2&K2&L2&M2)>2,LEFT(H2&I2&J2&K2&L2&M2,LEN(H2&I2&J2&K2&L2&M2)-2),"")
Hope this helps.

Resources