+ Reply to Thread
Results 1 to 11 of 11

How to copy a table including its checkboxes from one worksheet to another

  1. #1
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    How to copy a table including its checkboxes from one worksheet to another

    Hello all,

    I have created a userform that populates a preexisting table on a worksheet. This table contains ActiveX checkboxes in various locations. When the user submits the userform, the data is transferred to the table, including whether to "check" the checkboxes or leave them blank. That portion works properly. The vba code for the userform then needs to copy the completed table to another worksheet. This is where I am running into issues. The code is a simple row copy and paste at the bottom of the second worksheet:
    Please Login or Register  to view this content.
    But this does not copy or paste the various checkboxes. Do I need to link the checkboxes to a specific cell for them to be copied? If so, how do I do that? If it helps to have an example, one checkbox is named CenterfireCheckBox and is located roughly over cell W7. Its location in the original table is Top = 117, Left = 220.5.

    Any thoughts would be greatly appreciated!
    Last edited by jrooney7; 08-19-2018 at 05:12 PM.

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

    Re: How to copy a table including its checkboxes from one worksheet to another

    Why do you have ActiveX checkboxes? Do they do anything when you check\uncheck them? If the checkboxes had code and you did manage to copy the checkboxes to another sheet, it wouldn't copy their code?

    Alternatively, use Form-type checkboxes and the code below...
    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
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: How to copy a table including its checkboxes from one worksheet to another

    One of the checkboxes has a bit of code attached to the submission of the userform (what happens when the user clicks the submit command button):
    Please Login or Register  to view this content.
    Can this action be performed with Form checkboxes?

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

    Re: How to copy a table including its checkboxes from one worksheet to another

    Quote Originally Posted by jrooney7 View Post
    One of the checkboxes has a bit of code attached to the submission of the userform (what happens when the user clicks the submit command button):
    IDK. I can't tell from your limited description and code snippet what you're attempting to accomplish.

  5. #5
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: How to copy a table including its checkboxes from one worksheet to another

    Yes, my checkboxes have code associated. I tried replacing one with a Form control checkbox, but I don't know how to reference such a checkbox in the vba code. I tried recording a macro where I check and uncheck a form control checkbox, but the resulting macro code was blank. I don't think that form control checkboxes will work for me. So I'm back to the drawing board with how to use vba code to copy ActiveX checkboxes from one sheet to another.

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

    Re: How to copy a table including its checkboxes from one worksheet to another

    Again, I don't know what you are trying to do, but you can use form control checkboxes. You wouldn't get code for them by recording a macro.

    Put this macro in a standard code module e.g.; Module1, and assign this macro to a checkbox (right-click on the checkbox and select Assign macro).

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: How to copy a table including its checkboxes from one worksheet to another

    I'm sorry, I'll try to be more clear. My userform has 5 checkboxes and the userform code translates those to check or uncheck 5 corresponding checkboxes in the table on Sheet40 (named "CopyCC"). The table then needs to be copied, including the checkboxes to another worksheet, Sheet46 ("CopyCC2"). Then, if one particular checkbox is checked, the userform code deletes 2 rows from the table on Sheet46 and copies the remaining rows to the bottom of the official worksheet, Sheet3 ("Firearm").

    So I need to be able to identify individual checkboxes and have code associated with each one to correctly transfer the check/uncheck status from the userform to the table. Also, the user will only click the checkboxes on the userform, after that the code needs to simply look at the state of the one checkbox. Here are relevant portions of the userform code:

    Please Login or Register  to view this content.
    I was trying to simply my question, but maybe I overdid it! I hope this helps clear things up?

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

    Re: How to copy a table including its checkboxes from one worksheet to another

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  9. #9
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: How to copy a table including its checkboxes from one worksheet to another

    I've uploaded a sample workbook. As is, the userform will not submit as the code tries to call a checkbox (GRCSearchCheckBox) that is failing to copy to the CopyCC2 sheet. I put a note in the code indicating which section to remove temporarily to allow the userform to complete its submission actions.
    Attached Files Attached Files

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

    Re: How to copy a table including its checkboxes from one worksheet to another

    None of the ActiveX checkboxes on sheet CopyCC have code. Meaning, when the user checks\unchecks one of them on the worksheet, no code is executed. This makes things easier. You could replace all the ActiveX checkboxes with Form-type checkboxes.

    So now how do you reference form-type checkboxes in the code; Here are a couple of ways

    Note: Form-type checkbox values are xlOn or xlOff. Not True or False.

    By Name
    Sheets("CopyCC").Checkboxes("Check Box 1").Value = xlOn

    By index number:
    If Sheet46.Checkboxes(1).Value = xlOff Then Sheet46.Rows("16:17").Delete

    You could also link a cell to a Form-type checkbox and read the linked cell value or change the linked cell value. To link a cell, right-click on the checkbox and select Format Control on the pop-up context menu. Then select the Control tab on the dialog.

    If you are copying multiple tables to CopyCC2. The code will have to use offsets to know which linked cell goes to a given checkbox of a given copy of the table.

  11. #11
    Registered User
    Join Date
    10-04-2017
    Location
    North Carolina
    MS-Off Ver
    2013
    Posts
    29

    Re: How to copy a table including its checkboxes from one worksheet to another

    Great! I have changed the Checkboxes to form control checkboxes and they are now copying properly. I'm running into a sizing issue though. When they copy to the next sheet their height/width are different even though I have "lock aspect ratio" selected on the originals. Is there a way I can correct the sizes in the vba code? I've tried:

    Please Login or Register  to view this content.
    But it gives me an error on the first line? I've also tried:

    Please Login or Register  to view this content.
    But it didn't like that either...

+ 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] Copy duplicates including first instance to another worksheet
    By Newbikonob1 in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 01-23-2016, 11:41 AM
  2. Copy duplicates including first instance to another worksheet
    By Newbikonob1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-17-2016, 10:30 AM
  3. [SOLVED] how to copy worksheet including headers & footers
    By jmac1947 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-18-2014, 06:41 AM
  4. Copy entire worksheet including all colors
    By Trevorrow in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-06-2013, 01:45 PM
  5. Copy worksheet including named ranges not including macros
    By urungus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-07-2009, 01:38 PM
  6. sorting data (including checkboxes)
    By jeff.nglc in forum Excel General
    Replies: 3
    Last Post: 04-02-2008, 09:22 PM
  7. copy worksheet without including vba code
    By cedtech23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2006, 06:05 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