|
-
Jun 16th, 2008, 04:50 AM
#1
Thread Starter
Addicted Member
[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
-
Jun 16th, 2008, 05:04 AM
#2
Thread Starter
Addicted Member
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
-
Jun 16th, 2008, 06:21 AM
#3
Re: A Value in A Caption when Cell is Null
cmdres.caption = "Disabled"
or
cmdres.enabled = false
depending what you want to achieve
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 16th, 2008, 07:10 AM
#4
Thread Starter
Addicted Member
Re: A Value in A Caption when Cell is Null
I get an expected Expression Compile Error with this.Any Ideas?
-
Jun 16th, 2008, 07:25 AM
#5
Re: A Value in A Caption when Cell is Null
your else if has no condition, should be Else
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 16th, 2008, 08:02 AM
#6
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|