Find and Replace call for help!

Equious

New Member
Joined
May 20, 2014
Messages
2
Hey;

I'm a self proclaimed simpleton when it comes to excel. I've been scouring the internet, but I've been unable to find QUITE what I'm looking for.

I'm looking for a formula or VB script that searches all the cells in Column A on Sheet 1 for all the values in Column A on Sheet 2, and when it finds a match, it replaces the value of Column I for the corresponding row, with the value in Column B for the corresponding row in sheet 2.

The macro seems necessary as there are hundreds of entries and the order doesn't necessarily match. Being able to consolidate this into one step would REALLY save time.

Thanks for any assistance.

PS: This is specifically in Excel 2007, if that is of concern.

<colgroup><col></colgroup><tbody></tbody>
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
See if this does it (untested):
Code:
Sub Equious()
Dim lR1 As Long, lR2 As Long, vA1 As Variant, vA2 As Variant, i As Long, j As Long, ct As Long
lR1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
lR2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
vA1 = Sheets("Sheet1").Range("A1:A" & lR1).Value
vA2 = Sheets("Sheet2").Range("A1:B" & lR2).Value
Application.ScreenUpdating = False
For i = 1 To UBound(vA1, 1)
    For j = 1 To UBound(vA2, 1)
        If vA1(i, 1) = vA2(j, 1) Then
            ct = ct + 1
            Sheets("Sheet1").Cells(i, "I").Value = vA2(j, 2)
            Exit For
        End If
    Next j
Next i
Application.ScreenUpdating = True
If ct > 0 Then
    MsgBox ct & " matches found"
Else
    MsgBox "no matches found"
End If
End Sub
 
Upvote 0
See if this does it (untested):
Code:
Sub Equious()
Dim lR1 As Long, lR2 As Long, vA1 As Variant, vA2 As Variant, i As Long, j As Long, ct As Long
lR1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
lR2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
vA1 = Sheets("Sheet1").Range("A1:A" & lR1).Value
vA2 = Sheets("Sheet2").Range("A1:B" & lR2).Value
Application.ScreenUpdating = False
For i = 1 To UBound(vA1, 1)
    For j = 1 To UBound(vA2, 1)
        If vA1(i, 1) = vA2(j, 1) Then
            ct = ct + 1
            Sheets("Sheet1").Cells(i, "I").Value = vA2(j, 2)
            Exit For
        End If
    Next j
Next i
Application.ScreenUpdating = True
If ct > 0 Then
    MsgBox ct & " matches found"
Else
    MsgBox "no matches found"
End If
End Sub


Hey! .. I'm sorry it took so long to get back to you.. I hope I've not lost you. It SEEMS to function the way i want it to! It returned a lower number of matches than I would have expected however... is there a way to tweak this, such that, when a match ISN'T found, it outputs it to another place/list? .. That would actually make my day HAHA.
 
Upvote 0

Forum statistics

Threads
1,215,590
Messages
6,125,698
Members
449,250
Latest member
azur3

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