+ Reply to Thread
Results 1 to 10 of 10

Simple Macro works in 1 Excel file but not the other.

  1. #1
    Registered User
    Join Date
    10-22-2015
    Location
    Oneonta, ny
    MS-Off Ver
    2010
    Posts
    30

    Simple Macro works in 1 Excel file but not the other.

    Hello,

    A few weeks ago I asked a question about Assigning a Macro to a button using VBA in this thread here http://www.excelforum.com/excel-prog...fic-shape.html (hopefully the link works. Don't know how to link back without copying the link on top and pasting). The code worked great in one file but when I paste it in another file and change it to the appropriate names, it doesn't even get past the first line of Code. Anybody know why this is?

    Please Login or Register  to view this content.
    Any advice would be appreciated. Thanks.

    ~BBS
    Last edited by MsBBStacker; 12-03-2015 at 12:06 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Simple Macro works in 1 Excel file but not the other.

    The link worked fine

    Did you check teh sheet names in both your file and inthe macro - do they match?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Simple Macro works in 1 Excel file but not the other.

    Hi there,
    Is there a 'TestSrch' shape/button in the new file ?
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  4. #4
    Registered User
    Join Date
    10-22-2015
    Location
    Oneonta, ny
    MS-Off Ver
    2010
    Posts
    30

    Re: Simple Macro works in 1 Excel file but not the other.

    Yes, and Yes. I looked at it closely about 10 times

  5. #5
    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: Simple Macro works in 1 Excel file but not the other.

    If you get a subscript error, then there is no sheet in the activeworkbook named "Srch", or no button named "TestSrch"). There is no other possibility.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    10-22-2015
    Location
    Oneonta, ny
    MS-Off Ver
    2010
    Posts
    30

    Re: Simple Macro works in 1 Excel file but not the other.

    On a break from work. I did check my spelling with the Test Shapes here and found out that it is case sensitive. I wasn't able to get my other shapes to work in spite of spelling being correct. I'll try again when I get off work to see what I did wrong. Just wanted to know if it was possible I did something wrong outside of spelling.

  7. #7
    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: Simple Macro works in 1 Excel file but not the other.

    Accessing a collection with the name of a member is not case-sensitive:

    worksheets("sheet1") is the same as worksheets("SHEET1")

    shapes("bob") is the same as shapes("BOB")

    Text comparisons, however, are, by default, case-sensitive: "Bob" <> "bob"

  8. #8
    Registered User
    Join Date
    10-22-2015
    Location
    Oneonta, ny
    MS-Off Ver
    2010
    Posts
    30

    Re: Simple Macro works in 1 Excel file but not the other.

    Does Error 1004: Object Defined or Application Defined error make any sense?

  9. #9
    Registered User
    Join Date
    10-22-2015
    Location
    Oneonta, ny
    MS-Off Ver
    2010
    Posts
    30

    Re: Simple Macro works in 1 Excel file but not the other.

    I think I figured it out. The object was grouped with a bunch of other objects. When I ungrouped them, it still didn't work but for some reason, the group of objects that are now ungroup have their assigned macros. Will be testing if the rest do work. I'll mark this as solved if ungrouping the objects makes the macro work.

    Edit:

    Yep, definitely worked. Thanks for the education and help, especially with the lack of sensitivity of Caps vs Small letters. Very much appreciated.
    Last edited by MsBBStacker; 12-03-2015 at 12:08 AM.

  10. #10
    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: Simple Macro works in 1 Excel file but not the other.

    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] My macro only works in the excel file in which it created. How to generalise?
    By 1tane1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2013, 08:29 AM
  2. Excel rollup macro works on file share but not in SharePoint document library
    By mscurtin67 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-24-2013, 01:46 AM
  3. [SOLVED] Simple Macro Works for Me but 1004 Error for User
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-07-2013, 01:44 PM
  4. [SOLVED] Macro sends Excel file by Outlook - works in debug - not realtime
    By DJL in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2005, 10:25 AM
  5. Simple Macro, works in Excel 2002, 2003 but won't work in 2000
    By DJA in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2005, 01:05 PM
  6. Replies: 1
    Last Post: 06-21-2005, 12:05 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