ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   deleting mulitple rows when the checkbox value = true. (https://www.excelbanter.com/excel-discussion-misc-queries/128306-deleting-mulitple-rows-when-checkbox-value-%3D-true.html)

burgeee

deleting mulitple rows when the checkbox value = true.
 
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

Dave Peterson

deleting mulitple rows when the checkbox value = true.
 
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.

burgeee wrote:

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


--

Dave Peterson


All times are GMT +1. The time now is 04:43 AM.

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