Mikeymike_W
Board Regular
- Joined
- Feb 25, 2016
- Messages
- 171
Hi there,
I have a textbox (TBPsychology8) which is populated using the code below. I also want this box to be visible or invisible (depending on certain criteria) when you click a command button (CBDisc8).
The criteria are:
-If TBPsychology8 is blank and invisible then run the code to populate it and make the textbox visible.
- If TBPsychology8 already has text in it then all i want for it is to be made visible.
- If TBPsychology8 is already visible then make it invisible.
the code I have so far will show the textbox, populate it and when i click the command button a second time it will close it however it will not open the textbox again after this.
Thanks in advance for your help,
Mike
I have a textbox (TBPsychology8) which is populated using the code below. I also want this box to be visible or invisible (depending on certain criteria) when you click a command button (CBDisc8).
The criteria are:
-If TBPsychology8 is blank and invisible then run the code to populate it and make the textbox visible.
- If TBPsychology8 already has text in it then all i want for it is to be made visible.
- If TBPsychology8 is already visible then make it invisible.
the code I have so far will show the textbox, populate it and when i click the command button a second time it will close it however it will not open the textbox again after this.
Thanks in advance for your help,
Mike
VBA Code:
Private Sub CBPsychology8_Click()
If TBPsychology8.Visible = True Then
TBPsychology8.Visible = False
Exit Sub
End If
If TBPsychology8.Value <> "" And TBPsychology.Visible = False Then
TBPsychology8.Visible = True
Exit Sub
ElseIf TBPsychology8.Value = "" And TBPsychology8.Visible = False Then
TBPsychology8.Visible = True
Dim R As Worksheet
Dim myvalue3 As String
Dim T As Range
Set R = Worksheets("Interpretations")
myvalue3 = TextBox9.Value & " " & "Psychologically"
Set T = R.Range("A:MM").Find(myvalue3, LookIn:=xlValues, lookat:=xlWhole)
If Not T Is Nothing Then
TBPsychology8.Value = T.Offset(0, 1).Value
Else
Set R = Worksheets("Interpretations")
myvalue3 = Comboxmajor9.Value & " " & "Psychologically"
Set T = R.Range("A:MM").Find(myvalue3, LookIn:=xlValues, lookat:=xlWhole)
If Not T Is Nothing Then
TBPsychology8.Value = T.Offset(0, 1).Value
End If
End If
End If
End Sub