VBA search multiple sheets

sp00kster

New Member
Joined
Nov 25, 2006
Messages
42
I Could really use some help with converting an Excel formula into VB. Frankly I just don't know enough about VB to even get started and my current worksheets have ran out of realestate - thus I'm going to have to add a VB form search. Let me first put some insight into this. I have 12 identical laid out worksheets labeled from January thru December but with just different data. I need to be able to search all sheets in the range (B5:B2400) for a numerical match and if found return the left cell text value found in the range (A5:A2400) and if nothing / #N/A then "No records found". I tid bit of my working Excel formula is (the remaining months would be nested in this as well):

=IFERROR(INDEX(October!A5:A2400,MATCH(J16,October!B5:B2400,0)),IFERROR(INDEX(November!A5:A2400,MATCH(J16,November!B5:B2400,0)),INDEX(December!A5:A2400,MATCH(J16,December!B5:B2400,0))))

Tried piecing this together but not working
Code:
Private Sub CommandButton1_Click()

row_number = 5
Do
DoEvents
row_number = row_number + 1
rec_search = Sheets("January").Range("B" & row_number)
    If rec_search = TextBox1.Text Then
        TextBox2.Text = Sheets("January").Range("A" & row_number)
        'Else: TextBox2.Text = "Cloud Record Not Found"
    End If
Loop Until rec_search = ""

End Sub
Thanks for any help it is greatly appreciated
 
Last edited by a moderator:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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