Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8055893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:32:22+00:00 2026-06-05T08:32:22+00:00

I am trying to match 2 columns in one worksheet with 2 (or potentially

  • 0

I am trying to match 2 columns in one worksheet with 2 (or potentially more) columns in another worksheet.

I have posted a sample of my worksheet data which hopefully gives a good description of what I have been trying to do for the past week. I think I am on the right track but I don’t know how to properly reference between the two worksheets.

What I would like to do is look at Location 1 column, then see if that location references with my RefSheet in either location 1 or location 2.

If it does, I want to see if Location 2 then matches up in the somewhere in the same row on the RefSheet. If there is a match, I want to highlight the cell/cells yellow and give the ID number from RefSheet.

If there is no match I want to either highlight it red or no highlight.

Sheet All
A       B               C               D
ID  Location 1  Location 2  Given ID
1   West    North   
2   North   South   
3   South   East    
4   East    West    
5   East    East    
6   South   West




Sheet RefSheet
A       B               C   
ID  Location 1     Location 2
1   West            North
2   West            East
3   South           East
4   South           North



What it should look like on the original Worksheet
A               B               C           D
ID          Location 1  Location 2      Given ID
1(Yellow)   West            North           1
2(Yellow)   North           South           4
3(Yellow)   South           East            3
4(Yellow)   East            West            2
5(Red)      East            East    
6(Red)      South           West    

Here is my terrible Code

    Sub roadfinder()

    Dim lngLast As Long
    Dim lngCounter As Long
    Dim rCell As Range
    Dim lCnt As Long
    Dim nextIntersection
    Dim RefSheet As Worksheet
    Dim list As Worksheet

    Set intersections = ThisWorkbook.Sheets("RefSheet")
    Set crashes = ThisWorkbook.Sheets("All")


    Application.ScreenUpdating = False
    lngLast = Cells(Rows.Count, "B").End(xlUp).Row
    For lngCounter = 2 To lngLast
        With Cells(lngCounter, "B")

            For Each rCell In RefSheet.Range("B1", RefSheet.Cells(RefSheet.Rows.Count, 1)).Cells
            lCnt = lCnt + 1

                'I wasn't sure what to put as a reference to
                If .Value = "" Then
                    .Interior.ColorIndex = 6

                End If

            Next rCell
        End With
    Next lngCounter

    Application.ScreenUpdating = True

End Sub 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:32:24+00:00Added an answer on June 5, 2026 at 8:32 am

    Actually, it’s easy enough to do by a simple excel formula without any programming.
    Just put into cell 2 of your column for Given ID the following as an array formula:

    =SUM(SIGN((B2=Refsheet!$B$2:$B$5)*(C2=Refsheet!$C$2:$C$5)+(B2=Refsheet!$C$2:$C$5)*(C2=Refsheet!$B$2:$B$5))*Refsheet!$A$2:$A$5)
    

    And copy this formula through the whole column
    (I assume your input locations are in columns B, C, and your RefSheet range is in A2-C5, like you provided in your example)
    You’d better make named ranges on your Refsheet, though, so that formula will become:

    =SUM(SIGN((B2=Ref_Loc1)*(C2=Ref_Loc2)+(B2=Ref_Loc2)*(C2=Ref_Loc1))*Ref_ID)
    

    (Remember, it should be an array formula).
    Once you have the ID you can easily make Conditional formatting of your input cells based on whether the ID is 0 (meaning not found) or not.
    It is essential for refsheet location pairs to be unique,for ID to be numeric and not zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am trying to pull data from one table, compare columns to a variable,
I have a data that looks similar to this Tables contains more than one
I'm trying to make a MATCH of columns using multiple criteria, as in the
I am trying to match the text contents(character data) of an XML file with
I have GridView, which is not auto generating columns. In GridView there are 3
I have a script which returns 5 columns from a php result. I am
I have a script that is trying to compare specific data based on a
I have a really large table (around 32 columns and 1000+ rows) which I'm
I'm trying to find the rows that are in one table but not another,
I am trying to find a function to match two data frames of different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.