Array formula?

AnalogKid

New Member
Joined
Sep 23, 2009
Messages
12
I've searched on the board, but probably not using the right terms.

I have a list of part numbers from Column A - H and rows 1 - 452 that are on sheet 1 of the workbook.

I have been given a new list of part numbers that are columns A - C and rows 1-197 that I've copied into sheet 2 of the same workbook.

All I need to know is if any of the part numbers on Sheet 2 are already listed on Sheet 1.

Currently, I have a VLookup that references Column A of sheet 2, and compares to each individual Column of Sheet 1, so it takes 8 columns to complete the comparison. Then, I have 8 more columns to search for Column B and 8 more to search for Column C.

It is effective, inasmuch as it finds what I'm looking for.

It just seems like there ought to be a better way.

Any advice appreciated.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
AnalogKid,

I have a list of part numbers from Column A - H and rows 1 - 452 that are on sheet 1 of the workbook.

I have been given a new list of part numbers that are columns A - C and rows 1-197 that I've copied into sheet 2 of the same workbook.


Sample data before the macro (all data not shown for brevity):


Excel Workbook
ABCDEFGH
112345678
2910111213141516
31718192021222324
42526272829303132
53334353637383940
64142434445464748
Sheet1





Excel Workbook
ABC
11A1033
21221A44
3Z344366
4566588
57887110
Sheet2





After the macro (items on Sheet2 that are on Sheet1 are highlighted in Yellow):


Excel Workbook
ABC
11A1033
21221A44
3Z344366
4566588
57887110
Sheet2





Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Adding the Macro
1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL + C
2. Open your workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL + V
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


Code:
Option Explicit
Option Base 1
Sub MakeFoundYellow()
' hiker95, 01/20/2010
Dim a As Long, b As Long, c As Range, MyArray As Variant
Application.ScreenUpdating = False
MyArray = Sheets("Sheet1").Range("A1:H452")
With Sheets("Sheet2")
  For Each c In .Range("A1:C197")
     For a = LBound(MyArray, 1) To UBound(MyArray, 1)
      For b = LBound(MyArray, 2) To UBound(MyArray, 2)
        If MyArray(a, b) = c Then
          c.Interior.ColorIndex = 6
          GoTo MyNextc
        End If
      Next b
    Next a
MyNextc:
  Next c
End With
Application.ScreenUpdating = True
End Sub


Then run the "MakeFoundYellow" macro.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top