ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Delete old data when checkbox is unchecked (https://www.excelbanter.com/excel-discussion-misc-queries/123359-delete-old-data-when-checkbox-unchecked.html)

tnederlof

Delete old data when checkbox is unchecked
 
Right now I have a spreadsheet with checkboxes and each one uses the
following code:

Sub SelectYes1()
Range("f6").Value = "=sheet1!b2"
End Sub

All it does is takes a value off sheet1 and then puts it into f6 but
the only problem is, once it is unchecked the value isnt deleted so my
formula bases off of that still includes that number in the total.

Could someone let me know how to construct a macro that could delete
the cell f6 when the checkboxe is unchecked.

Thank you!

-Trevor


Dave Peterson

Delete old data when checkbox is unchecked
 
How about:

Sub SelectYes1()
if activesheet.checkboxes(application.caller) = xlon then
Range("f6").Value = "=sheet1!b2"
else
range("F6").value = 0 ' or "" to empty it
end if
End Sub

This works for checkboxes from the Forms toolbar.

And one of the nice things about these kinds of checkboxes is that you can
assign the same macro to each of them. But then you have to figure out someway
to know what to process.

You could use the name; you could use the location. Or anything else that was
unique.

tnederlof wrote:

Right now I have a spreadsheet with checkboxes and each one uses the
following code:

Sub SelectYes1()
Range("f6").Value = "=sheet1!b2"
End Sub

All it does is takes a value off sheet1 and then puts it into f6 but
the only problem is, once it is unchecked the value isnt deleted so my
formula bases off of that still includes that number in the total.

Could someone let me know how to construct a macro that could delete
the cell f6 when the checkboxe is unchecked.

Thank you!

-Trevor


--

Dave Peterson


All times are GMT +1. The time now is 08:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com