Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 563
- Office Version
- 365
- 2010
- Platform
- Windows
Code:
With ActiveSheet.Range("G:G")
Set rSearchRng = .Find(what:=Me.TextBox4.Value, lookat:=xlWhole, LookIn:=xlValues)
If Not rSearchRng Is Nothing Then
FirstRngCellAddress = rSearchRng.Address
Debug.Print rSearchRng.Address
rSearchRng.Select
Do
With ActiveSheet.Range("D:D")
Set rSearchLotValue = .Find(what:=Me.TextBox1.Value, lookat:=xlWhole, LookIn:=xlValues)
If Not rSearchLotValue Is Nothing Then
sFirstLotNumAddress = rSearchLotValue.Address
Debug.Print sFirstLotNumAddress
rSearchLotValue.Select
End If
End With
sProductCodeValue = rSearchRng.Offset(, -5).Value
sSearchLotValue = rSearchRng.Offset(, -3).Value
lProductTotal = 0
Do
If rSearchRng.Value = TextBox4.Value And sSearchLotValue = Me.TextBox1.Value And sProductCodeValue = TextBox2.Value Then
ActiveCell.Offset(, 4).Select
lProductTotal = lProductTotal + ActiveCell.Value
ActiveCell.Offset(, 2).Select
lProductTotal = lProductTotal + ActiveCell.Value
ActiveCell.Offset(, 2).Select
lProductTotal = lProductTotal + ActiveCell.Value
Debug.Print ActiveCell.Value
Set rSearchLotValue = Range("D:D").FindNext(rSearchLotValue)
rSearchLotValue.Select
Debug.Print sFirstLotNumAddress
Debug.Print rSearchLotValue.Address
Else
GoTo continue
End If
Loop While rSearchRng.Value = TextBox4.Value And sSearchLotValue = Me.TextBox1.Value And sProductCodeValue = TextBox2.Value And rSearchLotValue.Address <> sFirstLotNumAddress
Set rSearchRng = .FindNext(rSearchRng)
If rSearchRng Is Nothing Then
Exit Do
Else
Loop While Not rSearchRng Is Nothing And rSearchRng.Address <> FirstRngCellAddress
End If
continue:
ElseIf rSearchRng Is Nothing Then
MsgBox "The work order number " & frmSDPFLineSelect1.TextBox4.Value & " was not found for the " & sLineName & " line. Please confirm that the correct production line was selected and try again.", vbCritical, "Incorrect Selection"
ActiveWorkbook.Close
frmSDPFLineSelect1.Show
End If
End With
Code:
Set rSearchRng = .FindNext(rSearchRng) If rSearchRng Is Nothing Then
Exit Do
Else
Loop While Not rSearchRng Is Nothing And rSearchRng.Address <> FirstRngCellAddress
End If
Code:
Set rSearchRng = .FindNext(rSearchRng)