+ Reply to Thread
Results 1 to 4 of 4

Private vs not in sub function using Buttons

  1. #1
    Registered User
    Join Date
    08-11-2011
    Location
    Louisiana
    MS-Off Ver
    Excel 2016 & 365
    Posts
    39

    Private vs not in sub function using Buttons

    Hello,

    I have 2 sheets. One "monthly data" has all of my formulas. The 2nd one, "Data from ECS" has the actual data. So I went from a regular button associated with a Macro:

    Please Login or Register  to view this content.
    To an ActiveX button so that I could change it's color/formatting. I wasn't able to figure out how to link the new button to the macro so I just copied the code into the function that was created:

    Please Login or Register  to view this content.
    They both are supposed to do the same thing. The original function is located in the sheet called "Data from ECS", however the newer code is located in the sheet where the button is located.

    When I click the button, I get an error: Run-time error '1004': Select method of Range class failed.

    What am I doing wrong?

    TIA

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Private vs not in sub function using Buttons

    You want:

    Please Login or Register  to view this content.
    But you should really use a shape rather than an ActiveX button on a sheet:

    You're better off not using ActiveX controls on worksheets at all. They're incredibly unstable have a look here https://www.google.co.uk/webhp?sourc...eet%20controls and by using them, you're asking for trouble.

    Forms controls are much more reliable - they're in the same dropdown as the ActiveX ones, but are designed for use on worksheets - so you don't run into any stability issues, you can do most of the same things with them too and you can use them without using code.

  3. #3
    Registered User
    Join Date
    08-11-2011
    Location
    Louisiana
    MS-Off Ver
    Excel 2016 & 365
    Posts
    39

    Re: Private vs not in sub function using Buttons

    I used the button on the Form controls group, but I can't figure out how to change the color of the button. That's why I went to the ActiveX one.

    Also, the button is on the sheet with the formulas, not the one with the data. I want to make sure that those columns are cleared on the data sheet and not the main one with the formulas. I think the edit you gave me above would clear the columns on the wrong sheet.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Private vs not in sub function using Buttons

    ... but I can't figure out how to change the color of the button.
    You can use an autoshape and make it any color you like.
    Entia non sunt multiplicanda sine necessitate

+ 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. Issue with Private Radio buttons
    By klab16 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2016, 05:37 PM
  2. [SOLVED] Get a value from last used row using private function
    By pandemic in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-09-2015, 10:04 AM
  3. private function repeating
    By plato in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2012, 07:46 PM
  4. How to Keep a Function Private but Available at Different Levels?
    By Tirren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2008, 07:21 PM
  5. private sub macros and buttons
    By ponyboy1973 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2006, 05:38 PM
  6. Calling Private Sub/Function
    By AMK4 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-03-2006, 09:55 PM
  7. private variable: same module, other Sub/Function
    By Stefi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-05-2005, 05:05 AM

Tags for this Thread

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