+ Reply to Thread
Results 1 to 4 of 4

Using checkboxes to delete specific ranges of cells via command button

  1. #1
    Registered User
    Join Date
    03-03-2016
    Location
    Plymouth, UK
    MS-Off Ver
    2013 Professional Plus
    Posts
    2

    Question Using checkboxes to delete specific ranges of cells via command button

    Hello everyone,

    I am quite new to the forum, and although I have read the rules, please do let me know if I am breaking any. This is my first post, after all.

    I am extremely new to VBA and excel formulae and until very recently the most advanced procedure I was able to complete with Excel was sketching a scatter plot. I am compiling a database of sorts to serve me during my PhD. Through browsing the net for tutorial videos and forum posts, I was able to put together a VBA advanced filter, create a dynamic scatter plot and box plot with several useful functions, and a few very very simple macros to tidy the whole thing up.

    I am finding it difficult to navigate through my filtered data at times because there are simply too many columns. Sometimes I want to delete certain columns (not entire columns but cell ranges starting at row 29) so that I only have the data I need. This is simply enough done manually, however, I am not the only person to use the database, therefore I want to make it as straightforward as possible. What I want is to have checkboxes above each column header of my filtered data which I could check and then use a command button to delete the selected columns/cell ranges and shift the remaining cells left so there are no blank spaces. Needless to say, I need my advanced filter macro to still function after the columns have been deleted.

    I found a similar solution to what I want, which deletes entire rows in this thread. I don't know, however, how to adapt the solution to my needs.

    I have uploaded my current database for anyone to have a look.

    Any and all help would be much appreciated
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Using checkboxes to delete specific ranges of cells via command button

    Click on a few cells in row 27 and then click on green button in B27 and the contents of those columns are cleared.

    I did not know which columns of data to move to left. Not enough detail provided
    Please write out rule for which data is supposed to move leftwards after columns cleared (not all data the same, so are the numbers in groups?)


    1) Checkbox is mocked up by using the Marlett Font (in this font "a" looks like a "tick") . Much more flexible than traditional checkboxes!
    So click on any cell in range C27:AB27 and a tick will appear. Click again and it disappears
    The code that provides the (mock) checkbox is this

    Please Login or Register  to view this content.
    2) Colums cleared if tick (ie "a") in row 27, using this macro
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-03-2016
    Location
    Plymouth, UK
    MS-Off Ver
    2013 Professional Plus
    Posts
    2

    Re: Using checkboxes to delete specific ranges of cells via command button

    Thank you so much Kevin!

    This is almost exactly what I wanted, I half-solved my problem using Marlett checkboxes a few days ago, you can see what I came up with in the code below.

    Here is my code that I was using:
    Please Login or Register  to view this content.
    Instead of deleting all the checked columns using a button, what I did was deleted them 'on the fly', i.e. as each cell in a range was clicked, a Marlett checkbox appeared and the underlying column was deleted. What I could not figure out was how NOT to delete the cell containing the Marlett checkbox macro with the column.Thanks to your post I can now delete any range in the column I want! Thank you so very much for your reply!

    I have added reputation to your post!
    Last edited by Spykeeboy; 03-09-2016 at 06:49 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Using checkboxes to delete specific ranges of cells via command button

    thanks for adding to my reputation
    if you have all the answers you need please mark the thread as solved.
    kev

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA code to create command button. Print all sheets then delete command button.
    By Declamatory in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-15-2015, 05:18 PM
  2. Command Button to delete unlocked cells accross multiple workbooks
    By tommy2620 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-26-2015, 08:25 AM
  3. [SOLVED] Command Button to clear specific cells
    By jamiegfinch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-21-2014, 09:31 PM
  4. Clear the Specific Range of Cells Using a Command Button
    By Abinaya in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2014, 05:50 AM
  5. Command Button Code to Delete Unprotected Cells Only
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2011, 04:30 AM
  6. Delete Unprotected Cells with Command Button
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-14-2010, 04:51 AM
  7. checkboxes command button
    By spoko in forum Excel General
    Replies: 10
    Last Post: 07-21-2007, 10:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1