View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
obsessive obsessive is offline
external usenet poster
 
Posts: 12
Default Conditional BackColor Loop

I have a userform with 5 textboxes (Sample1, Sample2, ...etc). I want
to ensure the user is aware of what he or she is entering to prevent
inaccuracies. My goal is to create a loop for the following script and
another script (or combined script) to prohibit entries if the value
entered is <= -10 and = 10 the standard value.
This is the userform module I want to loop....

Private Sub ChkEditValues()
Dim lAnswer As Long


SampleVal = Val(Sample1.Text)
StandardVal = Val(Standard.Text)

'Checks values for plus or minus 3 and hilights backcolor if one of the
conditions are met'
If SampleVal <= (StandardVal - 3) Or SampleVal = (StandardVal + 3)
Then
Sample1.BackColor = &HFFFF&
lAnswer = MsgBox("Check the Hilighted Entries. If OK press YES",
vbYesNo, "Double Check")
If lAnswer = vbNo Then
Exit Sub
Else
Sample1.BackColor = &H80000005
PutData
MsgBox "Edits have been entered"
End If
Else
Sample1.BackColor = &H80000005

End If

End Sub