+ Reply to Thread
Results 1 to 11 of 11

Can I combine a simple "clear" macro with another that clears checkboxes?

  1. #1
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Can I combine a simple "clear" macro with another that clears checkboxes?

    I have two macros. One simply clears two separate columns on a spreadsheet. The other clears the marked checkboxes in another column. Is there a way to combine them, so that I can click just one button? Here's the code:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Maybe:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Thank you! I had no idea it would be so simple. Could I also do it in reverse?

    [CODESub Clear()
    '
    ' Clear Macro
    ' Clear Player and Special Request Column
    '

    '
    Range("I12:I93").Select
    Selection.ClearContents
    Range("G12:G93").Select
    Selection.ClearContents
    Range("G10").Select

    Call CheckBox416_Click()

    End Sub]Please Login or Register to view this content.[/CODE]

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Perhaps

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    John, I copied and pasted your code and got an error when I clicked on my "Clear" button.

    "Run-time error '1004':
    Unable to get the CheckBoxes property of the Worsheet Class."

    When I then clicked on "Debug", this line was highlighted: Set master = Active Sheet.CheckBoxes(Application.Caller)

    Is this because I assigned the checkboxes macro to another control? Do I need to delete that control first?

    I really appreciate your help!

  6. #6
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    It looks like you have a space after Active. Make sure its ActiveSheet.CheckBoxes...

    Also if both codes 'call' the other then you're going to end up with an endless loop of them going back and forth.
    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  7. #7
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Thank you, Solus. Here is what I have now, and I'm getting the same error message. When I use the "uncheck all" checkbox by itself (without the call), it works; and the "clear" button works alone; but they're not working in combination. I can't work on this again until tomorrow, so there is no rush. I REALLY appreciate your help so far!

    Please Login or Register  to view this content.

  8. #8
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Can you attach your workbook so we can see specifics?

    e/ Different types of checkboxes are handled different ways. From the looks of your code you have activeX controls but I'd like to be able to see the whole picture.
    Last edited by Solus Rankin; 08-21-2013 at 07:32 PM.

  9. #9
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Being a novice, I couldn't tell whether the check boxes were command or activeX. I know there's a difference, but someone else inserted the checkbox column, and I didn't know how to identify what type it was.

    I'm attaching the spreadsheet as it was before I started experimenting with combining the macros. I would prefer to click one button only (preferably the CLEAR button) to accomplish clearing G12:G93, I12:I93 and the check marks in column D.
    Attached Files Attached Files

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?


  11. #11
    Registered User
    Join Date
    08-19-2013
    Location
    Oviedo, FL
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Can I combine a simple "clear" macro with another that clears checkboxes?

    Great solution! Thank you, very much!

+ 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] Excel 2010 -- "Visual Basic" "Macros" and "Record Macro" all disabled.
    By NicholasL in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-07-2017, 06:11 AM
  2. [SOLVED] Combine "=IF" and "=HOUR" statement for cell formula
    By chriswhite1982 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-19-2013, 02:42 PM
  3. Macro to embed "clear content"
    By jw01 in forum Excel General
    Replies: 0
    Last Post: 12-05-2012, 12:33 PM
  4. Simple Macro - If Cell Value Is "X" then clear another cell
    By donjman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2011, 10:31 AM
  5. "Invalid property" after "Clear Form"
    By B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2006, 12:10 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