deleting mulitple rows when the checkbox value = true.

G

Guest

im setting up a spreadsheet system for as IT.

i have a series of rows, and at the end of each row theres a checkbox,
linked with a cell, which is either true or false. i also have a button
which, through macros, i would like to be able to delete all the rows that
are checked, by just clicking the remove button.
a) is this possible
b) can i then move all the remaining data up so there are no empty rows,
c) can someone please tell me the visual basic editor for this!

thankyouxxx
 
D

Dave Peterson

I put a bunch of checkboxes from the Forms toolbar -- not the control toolbox
toolbar -- on a worksheet in cells H1:H15.

Then I assigned this macro to each of them:

Option Explicit
Sub testme()
Dim CBX As CheckBox
Set CBX = ActiveSheet.CheckBoxes(Application.Caller)
If CBX.Value = xlOn Then
CBX.TopLeftCell.EntireRow.Resize(1, 7).Delete shift:=xlUp
CBX.Value = xlOff
End If
End Sub

It deletes the data in A:G of that row (if the checkbox is checked). Then
unchecks the checkbox.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Personally, I wouldn't do this.

You'll notice that there is no undo available after the code runs to delete and
shift the data up.

I'd just rightclick on the row header and choose delete row.
 

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

Top