Private Sub EnterButton_Click()
Dim MyPoNum As Long
Dim MyDate As Date
Dim MyQty As Long
Dim MyPNum As String
Dim MyRow As Long
Dim cmb As combobox, i As Integer
For i = 1 To 10
Set cmb = Me.Controls.Item("ComboBox" & i)
MyPoNum = Me.txt_PoNum.Value
MyDate = Me.txt_Date.Value
MyQty = Me.txt_Qty01.Value
MyPNum = cmb.Value
If MyPNum <> 0 Then
Worksheets("PieceParts").Activate
On Error Resume Next
Cells.Find(What:=MyPNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
If Err.Number <> 0 Then
Worksheets("VolumeParts").Activate
On Error Resume Next
Cells.Find(What:=MyPNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ElseIf Err.Number <> 0 Then
MsgBox ("Part Not Found")
End If
MyRow = ActiveCell.row
On Error Resume Next
Cells.Find(What:="Order Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(MyRow - 2, 0).Activate
ActiveCell.Value = MyDate
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = MyPoNum
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = MyQty
Next
Else
End If
Unload Me
End Sub
When I click the control button I get a Compile error: Next without For.
Thanks in advance for any help,
Rob
Dim MyPoNum As Long
Dim MyDate As Date
Dim MyQty As Long
Dim MyPNum As String
Dim MyRow As Long
Dim cmb As combobox, i As Integer
For i = 1 To 10
Set cmb = Me.Controls.Item("ComboBox" & i)
MyPoNum = Me.txt_PoNum.Value
MyDate = Me.txt_Date.Value
MyQty = Me.txt_Qty01.Value
MyPNum = cmb.Value
If MyPNum <> 0 Then
Worksheets("PieceParts").Activate
On Error Resume Next
Cells.Find(What:=MyPNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
If Err.Number <> 0 Then
Worksheets("VolumeParts").Activate
On Error Resume Next
Cells.Find(What:=MyPNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ElseIf Err.Number <> 0 Then
MsgBox ("Part Not Found")
End If
MyRow = ActiveCell.row
On Error Resume Next
Cells.Find(What:="Order Date", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(MyRow - 2, 0).Activate
ActiveCell.Value = MyDate
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = MyPoNum
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = MyQty
Next
Else
End If
Unload Me
End Sub
When I click the control button I get a Compile error: Next without For.
Thanks in advance for any help,
Rob