VB script to Add and remove data on a sheet with checkbox

samyjunior

New Member
Joined
Nov 12, 2017
Messages
1
am using the active X checkbox

I am trying
- to put data on two cells on another sheet once the checkbox is checked
- remove the contents I pasted on the sheet if unchecked
- Paste information on the next row if content is full


here is what I did and its not working ::

private Sub CheckBox4_Click()
With ThisWorkbook.Worksheets("MSI")
Dim ab As Range
Dim bc As Range

If CheckBox4 = True Then
Dim dat As Variant
Dim rng As Range
Dim i As Long
Set rng = ThisWorkbook.Worksheets("Q").Range("A5:A100")
dat = rng
For i = LBound(dat, 1) To UBound(dat, 1)
If dat(i, 1) <> "" Then

rng(i + 1, 1).Value = " help needed"
rng(i, 2).Value = " dial :123"
rng(i + 1, 1) = ab
rng(i, 2) = bc
End If

Next
Else

ab.Value = ""
bc.Value = ""

End If
End With
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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