Reset Data if Checkbox is unchecked in VBA

SpeedyFingers

New Member
Joined
Mar 26, 2012
Messages
38
Hello! I'm trying to figure out how to reset the data back to what it was if the checkbox has been checked then unchecked. My spreadsheet is basically inserting certian options if that checkbox is checked. For Example...

() Benefit Income
() Award Letter
() Proof of Receipt

If Benefit Income (Main Category ) is checked, the Award Letter and Proof of Receipt will populate. If Benefit Income is then unchecked the Award Letter and Proof of Receipt disappear.

There are other main categories that will be below and/or on top of this one so it needs to be able to move back to the place it was before the box was checked.

I have tried several things but haven't gotten anywhere. Please help! :eek:

Code:
Sub Docs1()
'
' Docs1 Macro
'
    Dim myBox As CheckBox
    Dim myCell As Range
    Dim cellRange As String
    Dim cboxLabel As String
    Dim linkedColumn As String
    Static AlreadyClicked As Boolean
    
    If Not AlreadyClicked Then
    AlreadyClicked = True
 Else
    AlreadyClicked = False
 End If
 
'
   If ActiveSheet.CheckBoxes(Application.Caller).Value = 1 Then
    MsgBox Application.Caller & " is checked"
  End If
    Range("A9:B18").Select
    Selection.Cut
    Range("A13").Select
    ActiveSheet.Paste
    With ActiveSheet
        For Each myCell In .Range("B9:B12").Cells
            With myCell
                Set myBox = .Parent.CheckBoxes.Add(Top:=.Top, Width:=.Width, Left:=.Left, Height:=.Height)
                With myBox
                    .LinkedCell = linkedColumn & myCell.Row
                    .Caption = cboxLabel
                    .Name = "checkbox_" & myCell.Address(0, 0)
                End With
                .NumberFormat = ";;;"
            End With
        Next myCell
    End With

    Sheets("Sheet2").Select
    Range("B1:B4").Select
    Selection.Copy
    Sheets("Sheet1").Select
    Range("C9").Select
    ActiveSheet.Paste
    
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top