Action Event, CheckBox, Add Row and Textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Howdy,

Alright, here is an interesting one. I have a check box that follows a
question in a questionnaire. The Checkbox is in a cell on the same row as the
question. When this checkbox is ticked, I need a new row to be created
underneath with a textbox to allow the user to give an explanation.

Your Sincer Texas Aggie.
 
Won't you have a problem if the user clicks on the checkbox, then unchecks it
and clicks on it again? Inserting a row each time the user checks the checkbox?

If you want that, you can use a checkbox from the forms toolbar and a single
macro.

Make sure you put the checkboxes completely within the row and assign each
checkbox this macro:

Option Explicit
Sub testme()
Dim myCBX As CheckBox
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

If myCBX.Value = xlOn Then
myCBX.TopLeftCell.Offset(1, 0).EntireRow.Insert
End If
End Sub

=======
Another option.

Put the same checkboxes in the worksheet. But instead of inserting a new row,
you could show a hidden row (or even hide the row).

If you like that, you can use a macro like:

Option Explicit
Sub testme()
Dim myCBX As CheckBox
Set myCBX = ActiveSheet.CheckBoxes(Application.Caller)

'to toggle viewing the row.
myCBX.TopLeftCell.Offset(1, 0).EntireRow.Hidden = CBool(myCBX.Value =
xlOff)

'to make it visible and never hide it again.
'If myCBX.Value = xlOn Then
' myCBX.TopLeftCell.Offset(1, 0).EntireRow.hidden = false
'End If

End Sub
 
It never accured to me about ticking and unticking, thanks for the heads up.
I think the second option is going to work. THanks for your time, hopefully I
will get to a point where I can help others as much as you have helped me.
Thanks again.

Your Sincer Texas Aggie.
 
Back
Top