+ Reply to Thread
Results 1 to 6 of 6

Moved Code from Worksheet Change to Command Button - Error Now

  1. #1
    Registered User
    Join Date
    07-21-2014
    Location
    Toronto, ON
    MS-Off Ver
    MS Office 2010
    Posts
    55

    Moved Code from Worksheet Change to Command Button - Error Now

    I have been staring at this for hours and can not figure out my error. Previously, I had the code below as a "Private Sub Worksheet_Change(ByVal Target As Range)". User would select from a few drop down menus on a workseet and the selections would open another worksheet in the file and unhide rows and columns where the criteria data would be. This worked perfectly. Then, it was determined that rather than automatically going to the worksheet after selecting the options from the drop downs, they wanted the ability to press a button to do the same thing. I moved the code to a macro for the button and I am getting an error message pop-up "Argument Not Optional" (error 449). I am sure it is something simple that I did wrong with simply copying and pasting the Worksheet Change code to a macro button but I can't see it. Any ideas?


    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,467

    Re: Moved Code from Worksheet Change to Command Button - Error Now

    A click event isn't passed a Target range, it's just an event that happens when a button is clicked.

    So, you won't have a Target value to test.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-21-2014
    Location
    Toronto, ON
    MS-Off Ver
    MS Office 2010
    Posts
    55

    Re: Moved Code from Worksheet Change to Command Button - Error Now

    aawww...so if I take out the target reference, I should be ok? Thank you for your reply.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,467

    Re: Moved Code from Worksheet Change to Command Button - Error Now

    Maybe. Not sure why you are testing Row 14 but the code all depends on that.

    So, you'd have:

    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    07-21-2014
    Location
    Toronto, ON
    MS-Off Ver
    MS Office 2010
    Posts
    55

    Re: Moved Code from Worksheet Change to Command Button - Error Now

    Again, I simply copied and pasted from a Worksheet change sub that was looking at that row. I have been doing this for 2 days straight and I can't think. I am new to vba so all the intricacies are still a bit foreign. I appreciate your help. Thanks again and have a great day!

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,467

    Re: Moved Code from Worksheet Change to Command Button - Error Now

    You're welcome.

+ 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] How can I change this worksheet code to a button hit?
    By JJBennett in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2013, 11:43 AM
  2. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  3. [SOLVED] Runtime Error using Command Button when Worksheet is Protected
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2012, 09:17 AM
  4. Worksheet Change Event to Show Command Button
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-21-2011, 04:39 PM
  5. Code for button errors due to worksheet name change
    By ge0rge in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-15-2008, 12:22 PM
  6. Command button code to write to worksheet and then open userform
    By Reidm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-18-2008, 10:33 AM
  7. Replies: 5
    Last Post: 06-23-2005, 06:05 PM

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