I've have this code and I've been trying to enable the user to only use the userform and not look into the others sheets with data, but the code I'm using only allows me to run it when the I'm on the data sheet. Same thing goes for my next and previous. can some one help me and explain what am I doing wrong?
Code
Private Sub search_Part_Click() Dim WS As Worksheet
Dim item_in_review
Set WS = Worksheets("Daily Ship Data")
Dim FoundOne As Range, LookInR As Range
Dim fAddress As String
Set LookInR = WS.Range("C1", Cells(Rows.Count, 3).End(xlUp))
With LookInR
Set FoundOne = .Find(What:=Me.Part.Text, LookAt:=xlPart)
If Not FoundOne Is Nothing Then
fAddress = FoundOne.Address
Do
Me.Lot.Text = FoundOne.Offset(0, -2).Value
Me.PartsDesc.Text = FoundOne.Offset(0, 1).Value
Me.Crate.Text = FoundOne.Offset(0, 7).Value
Me.Floor.Text = FoundOne.Offset(0, 10).Value
Me.DatePac.Text = FoundOne.Offset(0, 9).Value
Me.OgBin.Text = FoundOne.Offset(0, -1).Value
Set FoundOne = .FindNext(After:=FoundOne)
Loop While FoundOne.Address <> fAddress
End If
End With
Set LookInR = Nothing
Set FoundOne = Nothing
End Sub
Display More
and this is the code for my next button with the same issue
Code
Private Sub next_lots_Click()Dim WS As Worksheet
Set WS = Worksheets("Daily Ship Data")
If Me.Part.Text = "" Then Exit Sub
WS.Cells.Find(What:=Me.Part.Text, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Me.Lot.Text = ActiveCell.Offset(0, -2).Value
Me.PartsDesc.Text = ActiveCell.Offset(0, 1).Value
Me.Crate.Text = ActiveCell.Offset(0, 7).Value
Me.Floor.Text = ActiveCell.Offset(0, 10).Value
Me.DatePac.Text = ActiveCell.Offset(0, 9).Value
Me.OgBin.Text = ActiveCell.Offset(0, -1).Value
End Sub
Display More