Compare cell against multiple columns
Solved/Closed
Related:
- Compare cell against multiple columns
- Beyond compare - Download - File management
- Allow multiple downloads chrome - Guide
- Photoshop multiple selections - Guide
- How to delete multiple files on mac - Guide
- Display two columns in data validation list but return only one - Guide
5 responses
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 19, 2010 at 09:33 PM
Apr 19, 2010 at 09:33 PM
Very nifty trick of using count to locate the value. However you are right about hitting the limit of 7 nested if. It is time for you to go to macro world
Steps
1. Press ALT + F11 to enter VBE environment
2. Click on insert, and insert a new module
3. Paste the code given below
4. Use the function in your column. Example of usage is =FindHeader(B2,E:S )
Steps
1. Press ALT + F11 to enter VBE environment
2. Click on insert, and insert a new module
3. Paste the code given below
4. Use the function in your column. Example of usage is =FindHeader(B2,E:S )
Function FindHeader(LookForValue As Variant, LookInRange As Range) As Variant ' PURPOSE: To find a value in a given range and if found return the value ' found in first row of the the column in which the value exists. ' If value is not found then "" is returned 'CALL: =FindHeader(B2,E:S ) Dim rFound As Range ' where the value being searched found Dim firstCellAddress As String 'the address of the first cell in the range being looked Dim cell As Range ' cell of first 'The first part of the range being looked firstCellAddress = Left(LookInRange.Address, InStr(1, LookInRange.Address, ":") - 1) ' making sure if the last character is a number. If it is not a number then range is of ' sort A:Z instead of A1:Z50 If Not (IsNumeric(Right(firstCellAddress, 1))) Then firstCellAddress = firstCellAddress & 1 End If ' looking for the value Set rFound = LookInRange.Find( _ What:=LookForValue, _ After:=Range(firstCellAddress), _ LookIn:=xlFormulas, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) If (rFound Is Nothing) Then FindHeader = "" Else FindHeader = Cells(1, rFound.Column) End If Set rFound = Nothing End Function
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 19, 2010 at 10:27 AM
Apr 19, 2010 at 10:27 AM
Could you please upload a sample file on some shared site like https://authentification.site and post back here the link to allow better understanding of how it is now and how you foresee.
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Apr 19, 2010 at 10:50 AM
Apr 19, 2010 at 10:50 AM
See this
https://ccm.net/forum/affich-308205-match-with-conditional-format-in-excel-2003
Your problem seem to be very close to this issue
https://ccm.net/forum/affich-308205-match-with-conditional-format-in-excel-2003
Your problem seem to be very close to this issue
Didn't find the answer you are looking for?
Ask a question
Apr 20, 2010 at 08:13 AM
Great job! I can't begin to understand everything that is going on in this macro, but it is working very good. There is only one issue, if the formula is put in coulmn C without any data in B2, column C shows the header for column L.
To try and fix this, I did the following:
I have used =FindHeader(B2:$E:$T) (this adds a blank column, which now returns 0 if there is no data in B2, and will work just fine for me).
Question answered! Thank you very much!!!
Apr 20, 2010 at 09:04 AM
=IF(ISBLANK(B2), "",FindHeader(B2,$E:$T))
which says , if B2 is blank then show blank, else use the function
Apr 21, 2010 at 10:29 AM