VBA Array Lookup

gehusi

Board Regular
Joined
Jul 20, 2010
Messages
182
I have two cells (say B3 and D3) on Sheet1 which I would like to concatenate. On Sheet3 are columns (say A and B) which hold the values of previous entries of those two cells. I would like a macro which checks if the current concatenated value exists in those columns. If it finds a match, it should prompt the user to confirm an overwrite of the data in the matched row.

I hope that makes sense. Thanks in advance!
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
I have two cells (say B3 and D3) on Sheet1 which I would like to concatenate. On Sheet3 are columns (say A and B) which hold the values of previous entries of those two cells. I would like a macro which checks if the current concatenated value exists in those columns. If it finds a match, it should prompt the user to confirm an overwrite of the data in the matched row.

I hope that makes sense. Thanks in advance!

Give this a shot:

Code:
Sub checkRes()
Dim sh1 As Worksheet, sh2 As Worksheet, lr As Long, rng As Range
Set sh1 = Sheets(1)
Set sh2 = Sheets(2)
lr = sh2.Cells(Rows.Count, 1).End(xlUp).Row
Set rng = sh2.Range("A2:A" & lr)
For i = 2 To lr
If sh1.Range("B3").Value & sh1.Range("D3").Value = sh2.Cells(i, 1).Value & sh2.Cells(i, 2).Value Then
MsgBox "CHECK FOR OVERWRITE AT SHEET2, RANGE(" & Range(sh2.Cells(i, 1), sh2.Cells(i, 2)).Address & ")"
End If
Next
End Sub
Code:
 

gehusi

Board Regular
Joined
Jul 20, 2010
Messages
182
Thanks JLG - I was able to accomplish what I needed to with your help.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,233
Messages
5,594,963
Members
413,954
Latest member
mrsandy

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
Top