stillwillyboy
Technical User
I am using Input Boxes for entering the employee number, job number, hours and units (if units are needed) onto a sheet. I’m trying to use a GoTo statement to skip over the entry of units if the job is straight time, as opposed to piece work. When entering the employee number, job, hours and units (if units are needed), I should end up with the following:
EmplNumb Job Hours Units
1111 111 100 100
1111 181 100
1111 999 200 200
1111 19965 200
Note that the jobs 181 and 19965 do not have units. This is b/c they are straight time.
Below is my code for the hours entry. If the job needs units, then the proc should flow to the next Do for the entering of units. If the job does not have units, then I want to go back to the first Input box for a new employee number to start the process over.
Do ‘hours entry part of code
ValidEntry3 = False ' 'resets ValidEntry3 to false for each loop thru
TSEntry3 = InputBox("Enter the Hours")
If UCase(TSEntry3) = "EXIT" Then
MsgBox "You have decided to exit."
TSEntry1 = "" And TSEntry2 = "" And TSEntry3 = "" ‘clears any other info
Exit Sub
Else
If IsNumeric(TSEntry3) And TSEntry3 >= 10 And TSEntry3 <= 999 Then
ValidEntry3 = True
Else
MsgBox "Invalid Number of Hours. "
TSEntry3 = ""
End If
End If
Range("A65536").End(xlUp).Offset(0, 2) = TSEntry3
Loop Until ValidEntry3 = True
‘the above works as desired
'----the following is for skipping the units cell for straight time
With ActiveCell
If ActiveCell.Offset(0, 1).Value = 180 Or _
ActiveCell.Offset(0, 1).Value = 181 Or _
ActiveCell.Offset(0, 1).Value = 182 Or _
ActiveCell.Offset(0, 1).Value = 183 Or _
ActiveCell.Offset(0, 1).Value = 184 Or _
ActiveCell.Offset(0, 1).Value = 185 Or _
ActiveCell.Offset(0, 1).Value = 186 Or _
ActiveCell.Offset(0, 1).Value = 187 Or _
ActiveCell.Offset(0, 1).Value = 188 Or _
ActiveCell.Offset(0, 1).Value = 189 Or _
ActiveCell.Offset(0, 1).Value = 190 Or _
ActiveCell.Offset(0, 1).Value = 191 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 21 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 50 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 65 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 95 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 97 Then GoTo GoBacktoClientNumber
'End If
End With
‘The problem is with the Object Required error message. Isn’t the activecell my object?
If I change the line with 97 to:
Right(ActiveCell, 2).Offset(0, 1).Value = 97 Then
GoTo GoBacktoClientNumber
End if
End with
I then get the Object Req error after entering the hours.
Also, is there an easier way to do this than using the GoTo statement?
TIA
Bill
EmplNumb Job Hours Units
1111 111 100 100
1111 181 100
1111 999 200 200
1111 19965 200
Note that the jobs 181 and 19965 do not have units. This is b/c they are straight time.
Below is my code for the hours entry. If the job needs units, then the proc should flow to the next Do for the entering of units. If the job does not have units, then I want to go back to the first Input box for a new employee number to start the process over.
Do ‘hours entry part of code
ValidEntry3 = False ' 'resets ValidEntry3 to false for each loop thru
TSEntry3 = InputBox("Enter the Hours")
If UCase(TSEntry3) = "EXIT" Then
MsgBox "You have decided to exit."
TSEntry1 = "" And TSEntry2 = "" And TSEntry3 = "" ‘clears any other info
Exit Sub
Else
If IsNumeric(TSEntry3) And TSEntry3 >= 10 And TSEntry3 <= 999 Then
ValidEntry3 = True
Else
MsgBox "Invalid Number of Hours. "
TSEntry3 = ""
End If
End If
Range("A65536").End(xlUp).Offset(0, 2) = TSEntry3
Loop Until ValidEntry3 = True
‘the above works as desired
'----the following is for skipping the units cell for straight time
With ActiveCell
If ActiveCell.Offset(0, 1).Value = 180 Or _
ActiveCell.Offset(0, 1).Value = 181 Or _
ActiveCell.Offset(0, 1).Value = 182 Or _
ActiveCell.Offset(0, 1).Value = 183 Or _
ActiveCell.Offset(0, 1).Value = 184 Or _
ActiveCell.Offset(0, 1).Value = 185 Or _
ActiveCell.Offset(0, 1).Value = 186 Or _
ActiveCell.Offset(0, 1).Value = 187 Or _
ActiveCell.Offset(0, 1).Value = 188 Or _
ActiveCell.Offset(0, 1).Value = 189 Or _
ActiveCell.Offset(0, 1).Value = 190 Or _
ActiveCell.Offset(0, 1).Value = 191 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 21 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 50 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 65 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 95 Or _
Right(ActiveCell, 2).Offset(0, 1).Value = 97 Then GoTo GoBacktoClientNumber
'End If
End With
‘The problem is with the Object Required error message. Isn’t the activecell my object?
If I change the line with 97 to:
Right(ActiveCell, 2).Offset(0, 1).Value = 97 Then
GoTo GoBacktoClientNumber
End if
End with
I then get the Object Req error after entering the hours.
Also, is there an easier way to do this than using the GoTo statement?
TIA
Bill