+ Reply to Thread
Results 1 to 8 of 8

VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

  1. #1
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    I have a worksheet (see attached) with checkboxes linked to column Z to give a TRUE or FALSE. This code selects the rows if TRUE in column Z, and then I paste it elsewhere.


    Please Login or Register  to view this content.

    But what I'm trying to do is select a row if TRUE in column Z AND select the next rows as well until the next row with TRUE or FALSE. For example, in my sample workbook, I'd want to select 4:6 if F4 has a check and F7 doesn't. Does that make sense?


    Thanks!!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    Try something like this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    Alphafrog, that gives me an error message ... "Unable to get the Checkboxes property of the Worksheet class."

    Apparently this is because my checkboxes aren't ActiveX. So either I need to go back to the original idea of copying lines based on the TRUE or FALSE in column Z, or I need to modify the code I'm using to place the checkboxes to make them ActiveX. Any ideas on how to do either?


    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    Looking back on it, the title probably wasn't the best description. I'm using checkboxes, but really I'm looking to copy the rows with TRUE in column Z, then copy all rows underneath that one until it reaches a row that is <> TRUE (so either "" or FALSE). Make sense?

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    The code I suggested doesn't use the ActiveX-type checkbox. I tested it on your example workbook and it worked for me.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    Ok...I see what you did there. That's a cool trick, but it doesn't work for what I'm needing. It selects and copies only one group at a time, and I'll need it to do more than that. And instead of executing the code when they tick the box, I'd rather it happen when they push the "submit" button so that it copies multiple groupings.

    I imagine that the users will usually select all, or they may only select one or two of them. So I need this code to be able to select multiple groups, and probably non-sequentially.

    But thanks so much for helping me with this!

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    You could simply autofilter for TRUE on column Z.

  8. #8
    Forum Contributor
    Join Date
    02-18-2014
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2013
    Posts
    197

    Re: VBA Select Entire Row if Checkbox AND Select Down Until Next Checkbox

    I was able to come to a 2 step solution. It feels a bit ratchet, but it works



    Please Login or Register  to view this content.

+ 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. [SOLVED] a checkbox to select all checkboxes
    By almostgenius in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 07-22-2015, 11:26 AM
  2. Select All Checkboxes Checkbox That Also Calls Checkbox Macros
    By Intervigilium in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-23-2015, 06:41 PM
  3. select all checkbox in a sheet
    By nasim12w in forum Excel General
    Replies: 8
    Last Post: 12-27-2013, 11:07 AM
  4. How Do I select cells (with a checkbox) and sum them
    By spamunch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-12-2011, 06:42 PM
  5. Select All Checkbox
    By ChainsawDR in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-28-2009, 08:52 AM
  6. select product checkbox appear
    By pichai in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2008, 11:47 AM
  7. Checkbox to select image
    By Mack in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2006, 10:58 AM

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