Delete old data when checkbox is unchecked

  • Thread starter Thread starter tnederlof
  • Start date Start date
T

tnederlof

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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top