[RESOLVED] A Value in A Caption when Cell is Null
I have the following code. Problem is that sometimes Cell C1 is Null. When the Cell is Empty, I want to Disable the command Button and change the Caption to nothing to Resume. How can I do this?
Code:
Private Sub UserForm_Initialize()
Dim strCap As String
strCap = Sheets("Output").Range("C1").Value & " Statement Resumed."
CmdRes.Caption = strCap
End Sub
Re: A Value in A Caption when Cell is Null
I've tried the following but seems to be something wrong with the Else If.
Code:
Private Sub UserForm_Initialize()
Dim strCap As String
If Sheets("Output").Range("C1").Value <> "" Then
strCap = Sheets("Output").Range("C1").Value & " Statement Resumed."
CmdRes.Caption = strCap
CmdRes.Default = True
Else If
CmdRes.Caption = Disabled
CmdRes.Default = False
End If
End Sub
Re: A Value in A Caption when Cell is Null
cmdres.caption = "Disabled"
or
cmdres.enabled = false
depending what you want to achieve
Re: A Value in A Caption when Cell is Null
I get an expected Expression Compile Error with this.Any Ideas?
Re: A Value in A Caption when Cell is Null
your else if has no condition, should be Else
Re: A Value in A Caption when Cell is Null
Code:
Private Sub UserForm_Initialize()
Dim strCap As String
strCap = Sheets("Output").Range("C1").Value
If strCap <> "" Then
CmdRes.Caption = strCap & " Statement Resumed."
CmdRes.Default = True
Else
'--CmdRes.Caption = "Disabled"
'--CmdRes.Default = False
CmdRes.Enabled = False
End If
End Sub