ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Afternoon,
I am using the code below on a userform but before that code is allowed to run i wish to make sure that each Textbox has a value in it first otherwise show Msgbox to alert user.
Textboxes are 1 - 8
Please can you advise Thanks
So if all Textboxes have a value the run the code below.
If one or more have NO value then show Msgbox untill each have a value then run the below code.
Doesnt need to be fancy just something simple.
I am using the code below on a userform but before that code is allowed to run i wish to make sure that each Textbox has a value in it first otherwise show Msgbox to alert user.
Textboxes are 1 - 8
Please can you advise Thanks
So if all Textboxes have a value the run the code below.
If one or more have NO value then show Msgbox untill each have a value then run the below code.
Doesnt need to be fancy just something simple.
Rich (BB code):
Sub EnterData(Optional ByVal HideTextbox As Boolean)
Dim i As Long
Dim Box(1 To 2) As MSForms.TextBox
For i = 1 To 8
Set Box(1) = Me.Controls("TextBox" & (9 - i))
Set Box(2) = Me.Controls("TextBox" & i + 8)
Box(1).Visible = HideTextbox: Box(2).Visible = Not HideTextbox
If Not HideTextbox Then Box(2).Value = Box(1).Value Else _
Box(1).Value = "": Box(2).Value = ""
Erase Box
Next i
'Show/Hide Labels
Me.Label1.Visible = HideTextbox
Me.Label2.Visible = Not HideTextbox
End Sub