Search multiple worksheets in multiple workbook and return value beside matching cell

FordBiggs

New Member
Joined
Jul 17, 2012
Messages
5
Hi Guys,

I'm starting to get the hang of VBA but I can't seem to make this work. Currently, I have this working using the excel formula but it's very limited (both is the length of code and limited to search only in the same workbook). I'm currently using this:

Takes the value of A10 and searches through multiple sheets and returns adjacent value.
Code:
=IF(ISBLANK(A10),"-",VLOOKUP(A10,INDIRECT("'"&INDEX({"Sheet1";"Sheet2"},MATCH(1,--(COUNTIF(INDIRECT("'"&{"Sheet1";"Sheet2"}&"'!A1:A350"),A10)>0),0))&"'!A1:B100"),2,0))

But I need to upgrade this to VBA, basically I need it to do:

- I have a separate Worksheet just for the searching. Input something in Column A of said sheet, value of Cell will be searched in multiple other worksheets (or if possible, multiple workbooks) for a match in Range A1-A500 of worksheet.
- Once match is done - it takes the value of adjacent cell (column B) and returns to the original "searching" worksheet on an adjacent cell as well (column B).

I have this code from JoeMo which I'm trying to modify but still missing the actual searching codes.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A10:A500")) Is Nothing Then
    For Each C In Intersect(Target, Range("A10:A500"))
        If Not IsEmpty(C) Then
            ' Search code here
            C.Offset(0, 1).Value = "Return the value from adjacent cell of the search"
        Else
            C.Offset(0, 1).Value = "-"
        End If
    Next C
End If
End Sub

Would appreciate some help or at least a push in the right direction!

Thanks very much guys!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,246
Messages
6,170,999
Members
452,373
Latest member
TimReeks

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