View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] gwoodby@gmail.com is offline
external usenet poster
 
Posts: 58
Default listbox selection to load to new form

On Nov 1, 12:28 pm, dan dungan wrote:
Hi,

I'm wondering how you know it's not working.

Which line of code produces what error?

Dan
Private Function StrFind(StrList As String)

Dim SearchTxt As String
Dim rng As Range
Dim sh As Worksheet


With ThisWorkbook.ActiveSheet
If ListBox.Text = "" Then
GoTo ErrorHandler
End If


TextBox1.Text = LstBox.Text


SearchTxt = FrmSelection.LboxSelect.Text
Set sh = ActiveSheet
Set rng = sh.Cells.Find(What:=SearchTxt, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=False)
If Not rng Is Nothing Then
sh.Activate
' my code here
end if
End with


ErrorHandler:
MsgBox "Please Select One", vbOKOnly, "Error"
End Function

When you Click the Search Button ( this code) It will Search all 3
pages, However If you select a name thats not on Page 1 then It sends
you the error Message, instead of doing what i want it to do. Wich
would be make the sheet that its on active, Then Pull the data from
the cells to the right of it. I have the Code to Pull the data, the
issue was it wont activate the sheet any ideas?