+ Reply to Thread
Results 1 to 7 of 7

Macro works but not as a button

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Macro works but not as a button

    i have the following code that works fine as a macro. however when it is put into a button click event, it fails. can someone look at my code to see what the problem is?

    it fails initially on this line: Sheets("estimating1").Range("a1:i330").Select. The error is "Run time 1004, application defined or object defined error

    my code

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro works but not as a button

    Instead of selecting worksheets it is better to refer to the cell directly
    For example:
    In these two lines
    Please Login or Register  to view this content.
    You can use this line directly without select method
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Macro works but not as a button

    but it fails on this one line: Sheets("estimating1").Range("a1").Paste
    that is fully sourced, isn't it?
    Last edited by dmcgov; 03-18-2016 at 11:26 AM.

  4. #4
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro works but not as a button

    I have told you not to depend on Select method
    Please Login or Register  to view this content.
    Would be
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Macro works but not as a button

    so this is fully sourced. am i not typing this in correctly?

    Sheets("estimating1").Range("a1").Paste

    is that a valid command?

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Macro works but not as a button

    duplicate post

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Macro works but not as a button

    Try your modification and if encountered errors try to edit the yellow lines after clicking Debug

+ 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] macro works but when added to button macro, it fails, dont know why
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-06-2016, 01:20 PM
  2. Macro button works on my pc, no-one else's
    By ssu95bm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-04-2015, 01:47 PM
  3. issue with my macro - need serious help - tab through works, but the button doesn't
    By rgiglio7489 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2015, 03:43 AM
  4. Replies: 5
    Last Post: 05-04-2013, 01:42 PM
  5. Macro works correctly from VBE but not from button
    By tone640 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-15-2012, 10:45 AM
  6. Button Referencing Macro that works on any file
    By Sudheerp in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-15-2007, 07:12 AM
  7. Reverse a Macro - works like back button
    By spydor in forum Excel General
    Replies: 1
    Last Post: 01-02-2006, 08:45 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