I have a userform with 66 Text Boxes and 66 Scroll bars, which are paired up (the text box shows the value of the scroll bar, and if the text box is written in by the user, the scroll bar changes accordingly).
I have code that works for one text box/scroll bar pair and is easily replicated to all pairs (See below)
What I want is for a general system, such that if textbox A is updated, then the relevant scroll bar is updated, without doing it 66 times.
I'm thinking something to do with control types altho I've never used them before
All help appreciated
R
I have code that works for one text box/scroll bar pair and is easily replicated to all pairs (See below)
Code:
Private Sub sbEAResiDem_Change()
tbEAResiDem = sbEAResiDem / 2
End Sub
Private Sub tbEAResiDem_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Call TxtBoxValidation(Cancel, tbEAResiDem, sbEAResiDem)
If Cancel = False Then
sbEAResiDem = tbEAResiDem * 2
Else
tbEAResiDem = CurVal
End If
End Sub
Private Sub tbEAResiDem_Enter()
CurVal = sbEAResiDem / 2
End Sub
Function TxtBoxValidation(ByVal Cancel As MSForms.ReturnBoolean, TxtBx, ScrlBr)
If IsNumeric(TxtBx) = True Then
If TxtBx >= -100 And TxtBx <= 100 Then
ScrlBr = Round(2 * TxtBx, 0)
Else
Error_outofrange_per
TxtBx = CurVal
Cancel = True
End If
Else
Error_Numeric
TxtBx = CurVal
Cancel = True
End If
End Function
What I want is for a general system, such that if textbox A is updated, then the relevant scroll bar is updated, without doing it 66 times.
I'm thinking something to do with control types altho I've never used them before
All help appreciated
R