I want to compare 2 columns in excel and highlight duplicates in both. But there are two problems here:
1- I want this comparison to be case sensitive
2- I want to highlight the first occurrence only
It will be great if the script has 2 scenarios:
First: It highlights duplicates at both columns and between them too so the result should be like
In this case:
1) Highlight duplicates within column A, column B, and compare A and B columns to find duplicates too
2) Whenever it find duplicates it highlight ONLY first occurrence of it
Description:
A1 = kar32 > It is duplicate with A3 and it's the first occurrence
A5 = mic > It is duplicate with A6 and it's the first occurrence
A8 = fab > It is duplicate with B3
A9 = tea > It is duplicate with A11 and it's the first occurrence
B1 = kar32 > It is duplicate with A1
B2 = mic > It is duplicate with A5
B3 = fab > It is duplicate with A8
B4 = Fat > It is duplicate with B6 and it's the first occurrence
Second: It highlights first occurrence duplicates between both columns and ignores the only duplicates in the same column
In this case:
1) Highlight ONLY duplicates between columns A and B and ignores duplicates found in the same column
2) Whenever it find duplicates it highlight ONLY first occurrence of it
Description:
A1 = kar32 > It is duplicate with B1 and it's the first occurrence
A5 = mic > It is duplicate with B2 and it's the first occurrence
A8 = fab > It is duplicate with B3 and it's the first occurrence
As you see, it ignores to highlight A9 = tea, B4 = Fat because they didn't have duplicates in other column
Use conditional formatting.
One caveat, row 1 needs to be blank or titles that are not in the list being tested.
Select A2 and manage rules. Add a formula rule. Then add the following formula:
=AND(OR(SUMPRODUCT(EXACT($A:$A, A2)*1) > 1,SUMPRODUCT(EXACT($B:$B,A2)*1)>0),SUMPRODUCT(EXACT(A$1:A1,A2) *1)= 0)
Then change the "applies to" to the entire range of cells in column A.
Repeat for column B, but use the following formula:
=AND(OR(SUMPRODUCT(EXACT($A:$A, B2)*1) > 0,SUMPRODUCT(EXACT($B:$B,B2)*1)>1),SUMPRODUCT(EXACT(B$1:B1,B2) *1)= 0)
Related
On cell B5 I'm trying to get a TEXTJOIN with delimiter "," of INDEX MATCH to the price range you see on Table B. Because cell A5 contains "Apple" then "$$$" is one of the values I need, also A5 contains "Banana" then "$$" is the second value i need. Finally cell A5 contains "Pineapple" but because "$$$" is already was selected because of apple then no need to add it again.
Any help will be much appreciated.
What would I do if instead of 1 cell like A5, I will have multiple rows like this:
What would I do if I have a SKU that has only some of the Fruits and I have to use the formula based on the SKU?
With Excel 365, you can do:
=TEXTJOIN(",", 1, UNIQUE( XLOOKUP( FILTERXML( "<m><s>" & SUBSTITUTE( [#Fruits], "|", "</s><s>" ) & "</s></m>", "//s" ),
TableB[Fruit], TableB[Price Range],0)) )
=INDEX(Sheet17!$B$2:$B$50,MATCH(C5,Sheet17!$A$2:$A$50,0))
Short version:
This formula works when C5 is an exact match for text in Sheet 17 Column A, but I want to be able to match part of c5 (a keyword or phrase in C5) to that keyword or phrase in Sheet 17 Column A.
Details:
For my home budget and expense tracking, I'm using INDEX and MATCH to
return a piece of text (a label I use for the expenditure) from Sheet17 Column B
based on matching C5 (the description in my check register)
to a keyword or phrase in Column A Sheet17!$A$2:$A$50
AND IT WORKS when the text in C5 (in this case) is an exact match for the text in the column to look up against Sheet17!$A$2:$A$50
But I want to be able to match PART of C5 to Sheet 17 Column A and return the result
I've tried using wildcards around C5 but that doesn't help.
This works for exact matches between C5 and a keyword or phrase in Sheet 17 Col. A
=INDEX(Sheet17!$B$2:$B$50,MATCH(C5,Sheet17!$A$2:$A$50,0))
When I put wildcards around C5 such as ""&C5&""
I get the error message "Did not find value (the full text of C5) in the MATCH evaluation.
=INDEX(Sheet17!$B$2:$B$50, MATCH(FILTER(Sheet17!$A$2:$A$50,
SEARCH("*"&C5&"*", Sheet17!$A$2:$A$50)), Sheet17!$A$2:$A$50, 0))
_______________________________________________________________
=ARRAYFORMULA(IFERROR(VLOOKUP(REGEXEXTRACT(C3:C,
TEXTJOIN("|", 1, Sheet17!A2:A)), Sheet17!A:B, 2, 0)))
demo spreadsheet
So I have two columns of data and I want to add a date next to data that has two sets of values. So if A3 = Trucks and B3 = 2008 appear in the two columns I want C3 to have a date value of 11/1/2016. If these values A3 = Trucks and B3 = 2008 appear anywhere else in the data I want the date value to increase by 1 to 11/2/2016 and have that run until the data is fully queried.
This is what i understand from your question
if A3 = Trucks, B3 = 2008, C3 = 11/1/2016. then
if A10 = Trucks, B10 = 2008, then C10 = C3 +1 i.e. 11/2/2016
if my understanding is right, the below formula should work. Here is a google spreadsheet.
IF(MAX(--($A$1:A8=A9)*--($B$1:B8=B9)*ROW($A$1:A8))>0,OFFSET($C$1,MAX(--($A$1:A8=A9)*--($B$1:B8=B9)*ROW($A$1:A8))-1,0)+1,"New Date")
Please note the formula is an array formula i.e. press Ctrl+Shift+Enter after typing in cell. Also I have added an if clause, in case the item is appearing for the first time in the list, it will show "New Date".
I am going create a macro to convert two number to a range, e.g.
On excel cell A1 and A2, I input integer 1 and 5 respectively. The output will look like:
A3 1
A4 2
A5 3
A6 4
A7 5
How can I do that?
You can accomplish this without even using macros :)
in A3 type your first number.
On the Home tab go to the Editing section > Fill > Series...
Choose to have your series populated in Columns. Choose a stop value of 20 (or whatever)
Click OK
Now you will have a series of numbers 1-20 going down starting in Cell A3.
You can change your step value so that each number is incremented by 1, or 2 or 3 or whatever. You can also fill in rows instead of columns.
If you need it more automated than that just do all of that while recording a macro and see what it does then change the VBA to suit you more specific needs/come back here with some code to get advice on.
The Below COde will read the Content from the A1 and A2. According to the range it will display the result in the A series only.
enter code here
For i = Cells(1, 1) To Cells(1, 2)
Cells(1, i + 2) = i
Next i
I have got one column with 250 rows. The data fed is 0 and 1 randomly in these rows. I need to find the number of row between any two 1's. I need to write a macro for the same.For ex: if my column is as follow:
A1 0 B1 2
A2 0 B2 2
A3 0
A4 1
A5 0
A6 0
A7 1
A8 0
A9 0
A10 1
What I want is to check the entire column from A1 to A10. Starting from A1, my program would check for '1', it found in A4, it will continue to move down until it finds another '1'. Here it will move to A7. Now the result should be 'number of rows in-between' i.e 2 in this case. This result should be pasted in another column, lets say B1. This process need to be continued till my cursor reaches the B10 row. Please help.
This should do what you are after. It assumes that the data in column A is contiguous.
Sub helpSandeep()
Dim c As Range
Dim counting As Boolean
Dim zeroCount As Long
[B:B].ClearContents
[B1] = "Results"
For Each c In Sheets("Sheet1").[A1:A65536].Cells
If Len(c) = 0 Then
'Assuming that an empty cell means we are finished
Exit For
Else
If c.Value2 = 1 Then
'Update the results and reset the count
counting = True 'Avoids counting any initial zeroes as per your example
If zeroCount > 0 Then
[B65536].End(xlUp).Offset(1, 0) = zeroCount
End If
zeroCount = 0
Else
'Increment count, assuming we are actually counting
If counting Then
zeroCount = zeroCount + 1
End If
End If
End If
Next c
End Sub
Enter with Control+Shift+Enter to make it an array formula. In B1
=LARGE((ROW($A$1:$A$10))*($A$1:$A$10=1),SUM(--($A$1:$A$10=1))-(ROW()))-LARGE((ROW($A$1:$A$10))*($A$1:$A$10=1),SUM(--($A$1:$A$10=1))-(ROW()-1))-1
and fill down. The formula consists of subtracting two LARGE functions and then subtracting 1 from the results.
The first argument to the LARGE functions is an array that returns the row number for every entry that contains a 1.
(ROW($A$1:$A$10))*($A$1:$A$10=1)
The second argument to the LARGE functions is a SUM array formula that counts all the entries with a 1, then subtracts the current row number (or the current row number -1). For a formula in B1, this would return 3-1 (or 2, the count of all entries with one (3) less the row number (1)).
For the second LARGE function, the second argument would return 3-0 (3).
All of that says, give me the 2nd largest row for the entries that contain a 1 and subtract the 3rd largest row for the entries that contain a 1.
When you fill down to B2, that becomes: give me the 1st largest row for the entries that contain a 1 and subtract the 2nd largest row.
Finally we subtract 1 from the whole thing to make the result exclusive (rather than inclusive) of the rows that contain the 1's.
I know you asked for a macro, but you may find formulas more suitable.