jrobin5881
Technical User
I have a spreadsheet that is functioning basically as a surevey type of data form. I have sections of the spreadsheet whereby checkboxes are grouped under a category heading. On a different worksheet each of the category headings are stored in Row 1 to serve as field names. On the change event for each of the checkboxes the selection name finds the next blank cell under the category name and populates the cell. I have that working just fine.
Here's the issue. I need the selection name that populated the cell under the category name to be deleted if the user de-selects the check box. I can't seem to get that to happen with the coding I'm using. I tried recording a macro where I did a find and replace with a blank but that seems to be a hard way to go. I'm sure there must be a much easier way. I posted a sample of my code below and you can see where I was testing some code that would run on the False value but its hardcoded to a specific cell that it may or may not be in. The one commonality is that each response brought over will be in the same column.
Private Sub CheckBox1_Change()
Dim NextRow As Integer
If CheckBox1.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Eastern States"
End If
'If CheckBox1.Value = False Then
'Application.Worksheets("Sheet2").Cells(2, 6) = " "
'End If
End Sub
Private Sub CheckBox2_Change()
Dim NextRow As Integer
If CheckBox2.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Western States"
End If
'If CheckBox2.Value = False Then
'Application.Worksheets("Sheet2").Cells(2, 6) = " "
'End If
End Sub
Private Sub CheckBox3_Change()
Dim NextRow As Integer
If CheckBox3.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Northern States"
End If
End Sub
Here's the issue. I need the selection name that populated the cell under the category name to be deleted if the user de-selects the check box. I can't seem to get that to happen with the coding I'm using. I tried recording a macro where I did a find and replace with a blank but that seems to be a hard way to go. I'm sure there must be a much easier way. I posted a sample of my code below and you can see where I was testing some code that would run on the False value but its hardcoded to a specific cell that it may or may not be in. The one commonality is that each response brought over will be in the same column.
Private Sub CheckBox1_Change()
Dim NextRow As Integer
If CheckBox1.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Eastern States"
End If
'If CheckBox1.Value = False Then
'Application.Worksheets("Sheet2").Cells(2, 6) = " "
'End If
End Sub
Private Sub CheckBox2_Change()
Dim NextRow As Integer
If CheckBox2.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Western States"
End If
'If CheckBox2.Value = False Then
'Application.Worksheets("Sheet2").Cells(2, 6) = " "
'End If
End Sub
Private Sub CheckBox3_Change()
Dim NextRow As Integer
If CheckBox3.Value = True Then
NextRow = Worksheets!Sheet2.Range("f65536").End(xlUp).Row + 1
Application.Worksheets("Sheet2").Cells(NextRow, 6) = "Northern States"
End If
End Sub