I know that the following code works when detecting if a text box has either a 0 value or is blank it makes the checkbox invisible. If it contains any value greater than 0 then it becomes visible:
If (UserForm5.TextBox101.Text) = "" Then
UserForm5.CheckBox21.Visible = False
ElseIf (UserForm5.TextBox101.Text) = 0 Then
UserForm5.CheckBox21.Visible = False
Else
UserForm5.CheckBox21.Visible = True
End If
The problem is I have many Textboxes and Checkboxes and I was trying to right a Loop code that would reduce the lines of code required to turn many on, so I have tried the following in a sub routine many different way and can not get it to work:
Sub CheckBoxSetup()
Dim Count, CkBoxNum, TxBoxNum As Long
Dim TxStr, CkStr As String
Count = 0
CkBoxNum = 21
TxBoxNum = 101
TxStr = ("(UserForm5.TextBox" & TxBoxNum & ".Text)")
'MsgBox (TxStr)
CkStr = ("UserForm5.CheckBox" & CkBoxNum & ".Visible")
'MsgBox (CkStr)
Do Until Count = 20
TxStr = ("(UserForm5.TextBox" & TxBoxNum & ".Text)")
'MsgBox (TxStr)
CkStr = ("UserForm5.CheckBox" & CkBoxNum & ".Visible")
'MsgBox (CkStr)
If TxStr = "" Then
CkStr = False
ElseIf TxStr = 0 Then
CkStr = False
Else
CkStr = True
End If
CkBoxNum = CkBoxNum + 1
TxBoxNum = TxBoxNum + 1
Count = Count + 1
Loop
UserForm5.Show
End Sub
When enabling the MsgBoxes it does show the same strings but it does not work. Any help would be greatly appreciated.
On another note, How do I mark a post, Solved?
Bookmarks