Reputation: 2412
I have created a UserForm for adding comments to specific cells on Worksheet. I was using another Worksheet to store comments before. However now I have figured out that I can get values from Validation InputTitle and InputMessage directly.
My question is how I can check for "if Validation InputTitle or InputMessage is empty" separately for each one?
I have tried the following:
Private Sub CommandButton28_Click()
On Error Resume Next
Me.TextBox1.Value = ActiveCell.Validation.InputTitle
Me.TextBox2.Value = ActiveCell.Validation.InputMessage
End Sub
However this is updating only my first box (TextBox1) and TextBox2 have values even if Validation.InputMessage
is empty.
I have also tried:
Private Sub CommandButton28_Click()
If Not IsEmpty(ActiveCell.Validation.InputTitle) Then
Me.TextBox1.Value = ActiveCell.Validation.InputTitle
End If
If Not IsEmpty(ActiveCell.Validation.InputMessage) Then
Me.TextBox2.Value = ActiveCell.Validation.InputMessage
End If
End Sub
This does not even compile.
Upvotes: 0
Views: 152
Reputation: 42236
Try replacing:
If Not IsEmpty(ActiveCell.Validation.InputTitle) Then
Me.TextBox1.Value = ActiveCell.Validation.InputTitle
End If
If Not IsEmpty(ActiveCell.Validation.InputMessage) Then
Me.TextBox2.Value = ActiveCell.Validation.InputMessage
End If
with
If Not IsEmpty(ActiveCell.Validation.InputTitle) Then
Me.TextBox1.Value = ActiveCell.Validation.InputTitle
Else
Me.TextBox1.Value = ""
End If
If Not IsEmpty(ActiveCell.Validation.InputMessage) Then
Me.TextBox2.Value = ActiveCell.Validation.InputMessage
Else
Me.TextBox2.Value = ""
End If
Upvotes: 2
Reputation: 2412
This seems to be working:
Private Sub CommandButton28_Click()
On Error Resume Next
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.TextBox1.Value = ActiveCell.Validation.InputTitle
Me.TextBox2.Value = ActiveCell.Validation.InputMessage
End Sub
Upvotes: 0