I have a userform with 11 TextBoxes for users to enter in various downtime categories in minutes (integer value). They are tbD1, tbD2, ..., tbD11
What I want to do is loop through the inputs to ensure that they entered a value in a certain range. Here is what I have so far:
"Me.tbD(i)" is what gives me an error. I am not sure if there is any other syntax that I can use to loop through these variables?
Any help is greatly appreciated! Thanks!
What I want to do is loop through the inputs to ensure that they entered a value in a certain range. Here is what I have so far:
Code:
Dim DTsum As Integer 'sum of all entered downtime
Dim ShiftLength As Integer 'max shift length
DTsum = 0
ShiftLength = Sheet3.Range("D2").Value
'Check that the downtime doesn't exceed the maximum possible shift length
For i = 1 To 11
DTsum = DTsum + Me.tbD(i)
If Me.tbD(i) > ShiftLength Or Me.tbD(i) < 0 Or DTsum > ShiftLength Then
MsgBox ("Please ensure that the entered downtime doesn't exceed the maximum shift length.")
End If
Next i
"Me.tbD(i)" is what gives me an error. I am not sure if there is any other syntax that I can use to loop through these variables?
Any help is greatly appreciated! Thanks!