Transferring the Userform Textbox Values To a Single Cell As Comment Indicator

Hi,
I would like to explain my situation first.

[b][u]Scenario:[/u][/b]
I am using a UserForm which has few CheckBoxes and TextBoxes (next to the CheckBoxes). For Instance, the CheckBoxes are considered as criterias which are not fulfilled according to the user. The User checks the criterias and adds Comments in the respective TextBox next to the CheckBox.

[b][u]My Question:[/u][/b]
I need a code to merge the values in the TextBoxes and publish the value as a SINGLE Comment to a Cell.

I would be very grateful if anyone could help me in this regard.
Many Thanks:)
Kind Regards,
Shiva

UserForm
Vikas Verma's picture

Try this

Hi Shiva,

Use below mentioned code...hope it will help you..

Private Sub CommandButton1_Click()

Dim t As String
Dim i As Integer
Dim chb As CheckBox
Dim ctrl As msforms.Control, cnt As Long

cnt = 0
For Each ctrl In UserForm1.Controls
If TypeOf ctrl Is msforms.CheckBox Then
cnt = cnt + 1
End If
Next

For i = 1 To cnt
If Me.CheckBox1.Value = True Then
t = Me.TextBox1.Value
If Me.CheckBox2.Value = True Then
t = t & " " & Me.TextBox2.Value
If Me.CheckBox3.Value = True Then
t = t & " " & Me.TextBox3.Value

End If
End If
End If
Next i
Range("A3").AddComment t
End Sub

Happy coding