Morning,
Hope someone can help me out a bit here,
I have workbook with 2 worksheets in it, using vlookup the first spreadsheet pulls information from sheet2 relating to elements in the first worksheet
Currently I have a userform that finds any instance of the user inputted search and tells you which sheet its in and allows u link to them. I also have a number of text boxes that I want populated with the information found on only the activesheet, not both. Currently I get a type mismatch error, and whilst it populates the information in debug mode I also get a Error 2042 on the following code:
TextBox5.Text = Cells(rngFind.Row, 2)
My full code looks like this:
Any help would be greatly appreciated
Thanks,
Chris
Hope someone can help me out a bit here,
I have workbook with 2 worksheets in it, using vlookup the first spreadsheet pulls information from sheet2 relating to elements in the first worksheet
Currently I have a userform that finds any instance of the user inputted search and tells you which sheet its in and allows u link to them. I also have a number of text boxes that I want populated with the information found on only the activesheet, not both. Currently I get a type mismatch error, and whilst it populates the information in debug mode I also get a Error 2042 on the following code:
TextBox5.Text = Cells(rngFind.Row, 2)
My full code looks like this:
Code:
Option Explicit
Sub locate(Name As String, Data As Range)
Dim rngFind As Range
Dim strFirstFind As String
Dim Find As String
With Data
Set rngFind = ActiveWorkbook.Sheets(1).Cells.Find(Name, LookIn:=xlValues, LookAt:=xlPart)
If Not rngFind Is Nothing Then
strFirstFind = rngFind.Address
Do
If rngFind.Row > 1 Then
ListBox1.AddItem rngFind.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = Data.Parent.Name
ListBox1.List(ListBox1.ListCount - 1, 2) = Data.Parent.Name & "!" & rngFind.Address
'Find = rngFind.Cells
'Location
TextBox5.Text = Cells(rngFind.Row, 2)
'Speed
TextBox10.Text = Cells(rngFind.Row, 6)
'TextBox9.Text = Cells(rngFind.Row, 5)
'Suitability
TextBox7.Text = Cells(rngFind.Row, 4)
'IP Range
TextBox8.Text = Cells(rngFind.Row, 8)
End If
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstFind
End If
End With
End Sub
Private Sub CommandButton1_Click()
Dim shtSearch As Worksheet
ListBox1.Clear
For Each shtSearch In ThisWorkbook.Worksheets
locate TextBox1.Text, shtSearch.Range("A:M")
Next
If ListBox1.ListCount = 0 Then
ListBox1.AddItem "No Match Found"
ListBox1.List(0, 1) = ""
ListBox1.List(0, 2) = ""
'ListBox1.List(0, 3) = ""
End If
End Sub
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim strSheet As String
Dim strAddress As String
strSheet = ListBox1.List(ListBox1.ListIndex, 1)
strAddress = ListBox1.List(ListBox1.ListIndex, 2)
If strAddress <> "" Then
Worksheets(strSheet).Activate
Range(strAddress).Activate
End If
End Sub
Private Sub UserForm_Click()
End Sub
Any help would be greatly appreciated
Thanks,
Chris