Public
WithEvents
tbx
As
MSForms.TextBox
Dim
SABW
As
Double
Private
Sub
tbx_Change1()
SABW = Sheets(
"Tabelle1"
).Cells(2, 12)
If
tbx =
""
Or
tbx =
"-"
Then
tbx.BackColor = vbWhite
ElseIf
tbx > (SABW * 2)
Or
tbx < -(SABW * 2)
Then
tbx.BackColor = vbRed
Else
tbx.BackColor = vbGreen
End
If
End
Sub
und dem dazugehörigen Code in der UserForm
Private
Sub
UserForm_Initialize2()
For
Each
ctrl
In
Controls
If
TypeName(ctrl) =
"TextBox"
Then
If
Val(Right(ctrl.Name, 4)) >= 5089
And
Val(Right(ctrl.Name, 4)) <= 5107
Then
tbxcoll.Add
New
D_Strecke
Set
tbxcoll(tbxcoll.Count).tbx = ctrl
End
If
End
If
Next
ctrl
End
Sub
tbxcoll und ctrl sind global (also direkt nach
Option
Explicit) definiert.
Bin gerade ein wenig überfordert, Danke schon einmal!