0% found this document useful (0 votes)
24 views2 pages

Private Sub

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Private Sub

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Private Sub CommandButton1_Click()

Application.ScreenUpdating = False

Dim i As Long

Dim x As Long

Dim sh As Worksheet

Dim sht As Worksheet

Set sh = Worksheets(ComboBox1.Value)

Set sht = Worksheets("SearchData")

sht.Cells.Clear

i = sh.Range("B" & Rows.Count).End(xlUp).Row

sh.Range("A1:H1").AutoFilter Field:=2, Criteria1:="*" & Me.TextBox1.Value & "*"

sh.AutoFilter.Range.Copy sht.Range("A1")

Application.CutCopyMode = False

Me.ListBox1.ColumnCount = 8

Me.ListBox1.ColumnWidths = "30,150,60,40,40,40,60,40"

x = sht.Range("b" & Rows.Count).End(xlUp).Row

If x > 1 Then

Me.ListBox1.RowSource = "SearchData!A1:H" & x

MsgBox "Record Found"

Me.ListBox1.Selected(0) = True

Else

MsgBox "No Record Found"

End If

sh.AutoFilterMode = False

Application.ScreenUpdating = True
End Sub

Private Sub UserForm_Initialize()

Dim ws As Worksheet

For Each ws In Worksheets

If ws.Name <> "SearchData" Then

Me.ComboBox1.AddItem ws.Name

End If

Next ws

End Sub

You might also like