+ Reply to Thread
Results 1 to 10 of 10

Copying Check Boxes Formatting

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Copying Check Boxes Formatting

    Hi

    I am working on a check box based list for work. The requirement is for the check box to be linked to the cell that it is in and then for conditional formatting to be done so that if the box is checked it goes green and if it is blank it goes red. This is fine for individual cells, but when i try and copy the formatting and cells throughout the worksheet it links all the cells back to the original cell.

    Please can someone provide assistance with this. I have uploaded an exmample for your perusal.
    Attached Files Attached Files
    Last edited by stevop622; 09-04-2013 at 09:34 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,761

    Re: Copying Check Boxes Formatting

    There are two parts to your question and I am not sure which one is giving you trouble.

    If you create a Forms-style checkbox (that's the kind you have created) in a cell, and link that checkbox to a cell, the link will stay the same if you copy and paste that checkbox or the cell it is in. (The same is true of ActiveX checkboxes, but in general they work a little differently.) I do not know of a way for a checkbox to automatically relocate its linked cell based on its location if it is a pasted copy. I have, however, set these up with VBA code to initialize the setup.

    The other part of your issue is conditional formatting, but that's the easy part so maybe that's not your problem. You can easily do format painting to copy conditional formats once you have set up one cell the way you want it.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Copying Check Boxes Formatting

    Hi Jeff

    Thanks, the first point you mentioned is my problem. Is your VBA code generic enough to be able to use on my sheet?

    Also, is there a way of counting the number of ticks per column or row?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,761

    Re: Copying Check Boxes Formatting

    The second question is easier. If you have the checkboxes linked to cells, then counting the ticks in a row is

    =COUNTIF(5:5,TRUE)

    will count the number of checked boxes in row 5. Similarly for column C

    =COUNTIF(C:C,TRUE)

    This is not really counting the checkboxes, it's counting the cells they're linked to.

    For the VBA code I have to look a couple of things up. I never use Forms controls except to answer this type of question (I use ActiveX controls) so I'm not real sharp on using VBA to manipulate them. But it's doable, let me get back to you on that one.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,761

    Re: Copying Check Boxes Formatting

    In the file you attached you have 41 checkboxes. I think you have probably been copying and pasting on top of prior work. There are only 18 visible. I have cleaned that up and provided a macro to initialize the linked cells. This is a demo; you probably don't really need a button to do it.

    Demo file [CF for checkbox linked cells=CheckBox.xlsm]

    It sets the linked cell as the cell containing the top left corner of the checkbox. Be aware that this does not mean the top left corner of the actual box that gets checked--the checkbox control has a bigger outline that you can see when you right-click it.

    Image to illustrate the corner [checkboxcorner.jpg]

  6. #6
    Registered User
    Join Date
    04-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Copying Check Boxes Formatting

    Thanks. That is brilliant.

    I am struggling to use the code in my new workbook though? do i need to change any of it to adapt (sheet names etc)?

    And How do you copy the checkboxes without them duplicating (to avoid the problem of having multiple boxes under each other)? cos when i select the cells and copy paste, it adds boxes automatically?

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,761

    Re: Copying Check Boxes Formatting

    The code is in the same module for the sheet containing the checkboxes. Do you have more than one worksheet that contains checkboxes? There are two ways to handle this.
    One is to copy my code from the Sheet2 code module into the sheet module for every worksheet you have, and execute them each separately (you can click anywhere in the code and hit F5 to run it). No changes are necessary. That is probably good enough if you only have to do this once.

    Another option is to modify the code and put it in a new Module. Then it could loop through all sheets and execute the modified code at all once for all worksheets.

    I am assuming you have some knowledge of macro code. If not, then I will need to give you a little more explanation of how to do the above.

    I am not clear on your last question. Here's what I did to create this sheet: In cell C3, I created a checkbox so that top left corner was contained within C3. Then I copied the cell, and pasted it into the other 17 cells. I can't figure out how you created duplicate checkboxes in the same cells, except it's clear you must have pasted to those cells more than once.

  8. #8
    Registered User
    Join Date
    04-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    36

    Re: Copying Check Boxes Formatting

    Thanks, i have managed to get it sorted out. Really appreciate it.

  9. #9
    Registered User
    Join Date
    01-13-2018
    Location
    North Pole, AK
    MS-Off Ver
    2013
    Posts
    2

    Re: Copying Check Boxes Formatting

    6StringJazzer
    Thank you so much for this. Unfortunately, it seems my coding isn't as good as I thought. I named the Range in Question CheckBoxes, but I am still getting Runtime error 424 Object Required. When I select Debug, it highlights this line:
    >>For Each cb In CheckBoxes<<
    What am I missing?
    Many thanks in advance.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,761

    Re: Copying Check Boxes Formatting

    Sp0ck, welcome to the forum.

    However, your post does not seem to be related to this thread, which is 6 years old.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

+ 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. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  2. Formatting Check Boxes Issue
    By Freedan in forum Excel General
    Replies: 2
    Last Post: 09-07-2012, 08:36 AM
  3. Copying and pasting a list in order to print (using check boxes)
    By simjambra in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-12-2012, 02:18 PM
  4. Form Check Boxes Controlling Cell Formatting
    By karl_009 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2010, 06:27 PM
  5. Check boxes, and Conditional Formatting
    By jay in forum Excel General
    Replies: 1
    Last Post: 03-13-2007, 01:47 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