Matching cell values to two defined column ranges

Beard

New Member
Joined
May 24, 2015
Messages
14
Hello.

I have been trying to figure this out, but I have failed.

I have two ranges, A6:A29 and C5:C29.

In a group of cells that are not adjacent, if a number is entered in any of those cells, I would like to compare that number with the list of numbers I have in the two ranges.

If a match is found a popup box will appear with some text.

I have looked at VLOOKUP and MATCH, but I do not understand how to use the functions.

It is probably quite simple, but I cannot figure it out.

Thank you in advance.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Here's a good start.. Paste the below into your Sheets Code module


Excel 2012
ABCDEFG
1403
2
3
4
5429
6317277
7448163
8113396
9150440
10492117
11220337
12150143
13190403
14174394
15170421
16372344
17425335
18454213
19408330
20419496
21433198
22369489
23430114
24463313
25404347
26384440
27444330
28288311
29202314
Sheet1


Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRng As Range, Found As Range
If Target.Cells.Count > 1 Then Exit Sub
Set TargetRng = Range("F1:G3")   'Change this range to suit your needs
If Not Application.Intersect(Target, TargetRng) Is Nothing Then
With Range("A6:A29", "C5:C29")
    Set Found = .Find(What:=Target.Value)
    If Not Found Is Nothing Then
        MsgBox "Located number in Cell " & Found.Address
    Else
        MsgBox "Number not found"
    End If
End With
End If
End Sub
 
Upvote 0
Here's a good start.. Paste the below into your Sheets Code module

Excel 2012
ABCDEFG
1403
2
3
4
5429
6317277
7448163
8113396
9150440
10492117
11220337
12150143
13190403
14174394
15170421
16372344
17425335
18454213
19408330
20419496
21433198
22369489
23430114
24463313
25404347
26384440
27444330
28288311
29202314

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRng As Range, Found As Range
If Target.Cells.Count > 1 Then Exit Sub
Set TargetRng = Range("F1:G3")   'Change this range to suit your needs
If Not Application.Intersect(Target, TargetRng) Is Nothing Then
With Range("A6:A29", "C5:C29")
    Set Found = .Find(What:=Target.Value)
    If Not Found Is Nothing Then
        MsgBox "Located number in Cell " & Found.Address
    Else
        MsgBox "Number not found"
    End If
End With
End If
End Sub

This has been very helpful. Thank you.
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,382
Members
448,889
Latest member
TS_711

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