Search a specific cell from a range in excel - excel

I have a little problem concerning comparing different cells together, that's I need to compare each cell in column A, versus the whole column B and get the specified found cell in the adjacent column c cell.
I used this equation:
=IF(ISERROR(MATCH(A61,B:B, 0)), "No Match", "Match on Row " & MATCH(A61,B:B, 0))
and this is the result:
18 001220 No Match
19 001221 No Match
20 001222 No Match
21 001223 No Match
22 001224 No Match
101264 00040 Match on Row 121
Note that all data types are stored as text. and this is mandatory.
The problem is that this formula skips some data and doesn't collect them from column b except when being changed from text to general or number, which will damage my worksheet, as many cells start with zeros.

If your lookup_value can be either text or a number but you are always looking for it as text, then format the lookup_value with a format mask that covers both scenarios. It seems that most of your sample data is six digits with leading zeroes if necessary so TEXT(A61, "000000;#") should work to leave text values alone and format numbers to text with a minimum of six digits with leading zeroes if necessary.The zeroes in front of the semi-colon format numbers as text; the # behind the semi-colon leaves text alone.
Excel 2007 can drastically shorten that formula with IFERROR by removing the redundancy.
For your sample formula that would make,
=IFERROR("Match on Row " & MATCH(TEXT(A61, "000000;#"), B:B, 0), "No Match")

Related

Count cells that doesn't end with 1?

=(Countifs(B:B;”*”;F:F;”<>*1”))
Why doesn't this work?
I want to count all the rows in the sheet, except the ones that has a number that ends with 1 in column F. It just count all the rows, even the ones in column F that ends with 1.
How do I exclude those?
edit
Some more information!
This is a sample of the data:
Could be up to 8000 rows some days. Column B always says "Independent instruction" so I'm using that as a base to count all the rows. Column F contain only numbers, or blank cells (meaning a number will be added later). I still want to count those rows as well (that's blank). It's just the rows that has a number in column F that ends with 1 that I want to exclude!
SUMPRODUCT gives a bit more flexibility for criteria that involve more than straightforward string-matching:
=SUMPRODUCT(--(LEN($B:$B)>0),--(RIGHT($F:$F,1)<>"1"))
The array formula:
{=COUNT(IF((F:F<>"")*(MOD(F:F;10)<>1);F:F))}
will count all non empty cells in the conditions of your question.
Don't forget to press Ctrl+Shift+Enter to place the formula.
Why doesn't this work?
Apart from the fact that you have transcribed it incorrectly (i.e. missing =, and smart quotes ”) the 'F' condition in quotes is a Text value, a formatting issue #BigBen has mentioned in connection with the 'B' values.
You say It just count all the rows so, syntactically corrected, your formula must be working on (a) all 'B's populated (with Text) and (b) all 'F's Numeric. As 1 and "1" are not the same, none of your entries in ColumnF will be excluded by your attempt (none end in "1", though presumably some do end in 1).
#Pspl's A works because its condition (for the 'F's) is based on MOD (applies to Number format values) and #jsheeran's A (my preference) because RIGHT is a string function that returns Text format even from a Number format value.
Put another way, with say 1 in F1, =F1="1" returns FALSE (so =F1<>"1" and =F1<>"*1" return TRUE - that would not suit you) whereas =RIGHT(F1)="1" returns TRUE (or, to suit you, RIGHT(F1)<>"1" returns FALSE).
You can try to use a combination of SUM and IF. Remember to adjust the formula to match your Excel formatting, i.e. replace commas (,) with semicolon (;).
This is an array formula (enter with Ctrl+Shift+Enter)
=SUM(IF(MOD($F$2:$F$25,10)<>1,1,0))
Result (updated with your data set):
When pasting the image into merged cells, the error looks like that:
So you need to make sure the formula is pasted into a single (not merged) cell.
Array formula for values greater than 1000:
=SUM(IF((MOD($F$2:$F$25,10)<>1)*($F$2:$F$25>1000),1,0))
Array formula for values less than 1000:
=SUM(IF((MOD($F$2:$F$25,10)<>1)*($F$2:$F$25<1000),1,0))
Example:

Stuck combining 3 numbers

I need a formula in Excel, not VBA please, forbidden to have such functions on my work machine. My situation is I need a number from cell A, which is a result from Today(), combined with a number from cell B, which is a result from Now(), combined with a number from cell C which is a text number, to output as a single number.
Example:
Cell A1 Cell A2 Cell A3
Formula: TODAY() NOW() 17709
Displays: 1011 1423 17709
Needed: 1011142317709
What I'm trying is this, which is a fail: =TEXT(O21,yy-mm)&""&TEXT(P21,hh,mm)&"""&VALUE(Q21)
=TEXT(O21,"yymm")&""&TEXT(P21,"hhmm")&""&VALUE(Q21)
Placed in quotes the number format and removed extra quote though not sure why you are adding null to the string.
To match the sample output OP provided the formula would be:
=TEXT(A1,"mmdd")&""&TEXT(B1,"hhmm")&VALUE(C1)
If you do not need leading zeroes to fill 5 digit placeholders for the value in Q21,
=TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "0")
'possibly,
=TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "0")
If you do need leading zeroes to fill 5 digit placeholders for the value in Q21,
=TEXT(NOW(),"yymmhhmm")&TEXT(Q21, "00000")
'possibly,
=TEXT(NOW(),"mmddhhmm")&TEXT(Q21, "00000")

Return Dates of Three Consecutive Values in a Row

I have a data file and I need to return the dates of when the value (MaxT) is greater than or equal to 30 (>=30) for 3 consecutive days.
Data File:
Date, MaxT
1872-03-01,31
1872-03-02,29
1872-03-03,37
1872-03-04,40
1872-03-05,22
1872-03-06,9
1872-03-07,28
1872-03-08,31
1872-03-09,35
1872-03-10,37
1872-03-11,44
1872-03-12,29
1872-03-13,35
1872-03-14,48
1872-03-15,33
1872-03-16,31
1872-03-17,38
1872-03-18,31
1872-03-19,42
1872-03-20,20
1872-03-21,24
1872-03-22,31
I have attempted to figure this out using the following code but, I do not think I'm even in the ballpark...
Attempted Code:
=SUMPRODUCT(--(FREQUENCY(IF(B2:B23>=30,ROW(B2:B23)),IF(B2:B23>=30,ROW(B2:B23)))=3))
I'm assuming that your data file consists of 2 columns Date and Max T. If they are delimited by commas, you need to split them to 2 different columns using Text to columns delimited by commas ,.
The Date should be in Column A and Max T in Column B.
Enter the below formula in cellC2 and drag down,
=IF(AND(B2>=30,B3>=30,B4>=30),"Consecutive Range","")
The starting of the consecutive range of values greater than 30 will be shown in the output as above. You could then use a filter of some other excel function like Index-Match to get the corresponding dates. Hope this helps.
Alright, I got it to work, but I'm not entirely sure how you would make it work without separating the formula into multiple cells.
One potential solution would be to write some of the formulas into a sheet that's in the background, place the final part of the formula in the front sheet and have it reference the "hidden" bits of the formula.
First, I wrote the data in columns... "Date" in Column A, "MaxT" in Column B.
The first part of the formula is written in cell D2:
=IF(B2>=30,B2,"")
The next part of the formula is written in cell E2:
=COUNT(D2:D4)
The last part of the formula is written in cell F2:
=IF(E2=3,A2&","&A3&","&A4,"")
The result of this formula, in column F, there are 7 cells that have three dates written in them, separated by a comma.
Note that you can make any character or string of text separate the three displayed dates by replacing the commas that are in-between the ampersand, quote text:
(&","&) can become (&"anything you want"&)
From here, auto-fill the formulas to the relevant cells.
EDIT:
One way to shorten the code is to add the COUNT formula into the last IF statement like this:
=IF(COUNT(D2:D4)=3,A9&","&A10&","&A11,"")
I do still think that the first IF statement will need to be separate from the rest of the formula, though.
EDIT #2
Here is the code in one single cell:
=IF(AND(B2>=30,B3>=30,B4>=30), A2&","&A3&","&A4,"")
Which will display three dates that are located within Column A, current row & the next two rows below it.
This code still produces 7 lines of results with the data that you've provided.

How to combine specific letters and numbers from different cells in Excel?

I have 3 names that I want to combine to create something unique - I've used "CONCATENATE", but to no avail.
Example:
Paper (will always be different)
000001 (This will be sequential, the next row will have 000002)
Plastic (will always be different)
Essentially I want to input all three items in different cells and have the fourth cell output the following:
Pa000001Pl
Thank you.
Using & between objects is an alternative way to concatenate in excel:
=LEFT(A1,2) & B1 & LEFT(C1,2)
See http://fiveminutelessons.com/learn-microsoft-excel/extract-text-cell-excel for info on how to extract text from cells. (Examples: LEFT(), RIGHT(), MID(),FIND().
See https://support.office.com/en-za/article/Combine-the-contents-of-multiple-cells-3a86c317-6b91-4f1d-8781-203320aefdce for info on how to combine text from cells.
If you want to keep the 00000's in the number you need to make sure to format the cells containing the numbers as Text.
You could do this using the TEXT() function on the fly:
=LEFT(A1,2) & TEXT(B1,"000000") & LEFT(C1,2)
The six 0's tell Excel to create a number 6 digits long and replace any 0 with a non-zero number from your cell. So if B1 is 1, TEXT(B1,"000000") will convert it to 000001. If B11 is 11, TEXT(B11,"000000") will convert it to 000011.
If you instead want to ensure that the same number of 0's remain in front of your non-zero numbers, you could use the CONCATENATE() function:
=LEFT(A1,2) & CONCATENATE(B1,"00000") & LEFT(C1,2)
This would always insert five 0's in front of whatever number is listed in B1.
With values in A1, B1, and C1, in another cell enter:
=LEFT(A1,2)&TEXT(B1,"00000")&LEFT(C1,2)
This is needed to preserve the leading zeros if those leading zeros are the result of formatting cell B1
Assuming your values are in the 2nd Row
=LEFT(A2,2) & B2 & LEFT(C2,2)

Excel formula to check for duplicate words

I require an excel formula to check if any words are being duplicated in any column in a row. My sample row is below columns separated by a ','.
Column No: E221, F221, G221, H221
Column Text: Sam, John/Sam/Smith, Smith, Kyle
Above Sam & Smith names are being repeated so the words should be highlighted in red.
Excel File Link:
https://docs.google.com/spreadsheets/d/1D6PZWtbk_2IVEA4l1noFzKRFu0quXSTAewmL41xOnlo/edit?usp=sharing
I think this does the job (assuming you have your data in B1:F1):-
=if(b1="",0,
SUM(1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6})),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{2;3;4;5;6;7}))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6}))+1),"/"&$A$1:A$1&"/"))))
+SUM(1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6})),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{2;3;4;5;6;7}))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6}))+1),"/"&C$1:$G$1&"/"))))
)
It extracts each name in each cell and tries to match it with all other cells but because it uses array constants you can't use it directly in conditional formatting: you would have to put this in (say) B2:F2 and base your conditional formatting on it, or else use an even longer formula.
It's an array formula, so need to enter it with Ctrl Shift Enter
Here is an improved formula. Previously I was matching cells to the left and right of the current cell: this one matches all cells including the current cell and subtracts the number of matches where the current cell matches with itself:-
=if(b1="",0,
SUM(1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6})),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{2;3;4;5;6;7}))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",{1;2;3;4;5;6}))+1),"/"&$B$1:$F$1&"/"))))
-(LEN(B1)-LEN(SUBSTITUTE(B1,"/",""))+1)
)
If you wanted a formula that you could use directly in conditional formatting, I think you would have to enumerate all possible matches for all possible substrings separately which is rather tedious:-
=if(b1="",0,
SUM(
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",1)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",2))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",1))+1),"/"&$B$1:$F$1&"/"))),
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",2)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",3))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",2))+1),"/"&$B$1:$F$1&"/"))),
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",3)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",4))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",3))+1),"/"&$B$1:$F$1&"/"))),
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",4)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",5))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",4))+1),"/"&$B$1:$F$1&"/"))),
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",5)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",6))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",5))+1),"/"&$B$1:$F$1&"/"))),
1-(ISERROR(FIND(MID("/"&B1&"/",FIND("|",SUBSTITUTE("/"&B1&"/","/","|",6)),FIND("|",SUBSTITUTE("/"&B1&"/","/","|",7))-FIND("|",SUBSTITUTE("/"&B1&"/","/","|",6))+1),"/"&$B$1:$F$1&"/"))))
-(LEN(B1)-LEN(SUBSTITUTE(B1,"/",""))+1)
)

Resources