+ Reply to Thread
Results 1 to 13 of 13

Excel 97 macro error

  1. #1
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Excel 97 macro error

    I have an Excel 97 application with several macros and all seem to run fine in Excel 2007 except for one error that I don't seem to be able to resolve.

    The code is

    Please Login or Register  to view this content.
    Very rarely, it seems to work but most times the macro fails on the second line of the above three lines of code.

    Thanks.......Steve
    Last edited by shg; 01-09-2011 at 02:36 PM. Reason: fix code tag

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Excel 97 macro erro

    Try

    Please Login or Register  to view this content.
    Martin

  3. #3
    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: Excel 97 macro erro

    SpeciaCells will error if there are no cells of the designated type within the range, which you can work around.

    In your code you are selecting a worksheet, and then immediately applying the SpecialCells method without explicitly designating the cells to apply it to. What are you trying to do?
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro erro

    This is a project I inherited. It appears that this macro is taking a year end spreadsheet and all the amount fields to zero in order to start a new year. Based on what you said, I'm checking to see that the amount fields are formatted such that the macro will not error.

  5. #5
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro erro

    Actually, it seems that the error prone code is trying to reset just fields that have formulas

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel 97 macro erro

    No, it is looking for cells that contain hardcoded numbers (i.e. not the result of a formula). However, as shg said, it assumes the current selection is correct. If you have only one cell selected, it will search the whole sheet, but if you have more than one cell selected, it will search only the selected cells.
    Remember what the dormouse said
    Feed your head

  7. #7
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro erro

    I was trying to get this macro code working in 2007 and then upgrade to 2010. The 2010 upgrade is desirable but not absolutely necessary. But I tried opening the spreadsheet in 2010 and Excel displayed this message:
    This workbook has lost its VBA project, ActiveX controls and any other programmability-related features.
    Not sure how to proceed. Maybe just forget the 2010 upgrade

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel 97 macro erro

    Did you install VBA when you installed 2010? If not, that would happen.

  9. #9
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro erro

    Thanks for your answer. I opened Excel 2010, went to File/Options/Add-ins and enabled Analysis ToolPak and Analysis ToolPak - VBA. I still get the same message when trying to open the Excel 97 spreadsheet containing macros.

  10. #10
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro erro

    Thanks, I'll look at it. It seems to do a select of several cells before the search. I'll "STEP" through the code.

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Excel 97 macro error

    The Analysis Toolpak is irrelevant. I'm asking whether you installed VBA when you installed Office? If not, your code will be removed, as you indicated.

  12. #12
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro error

    Thanks. I'll go back and re-install.

  13. #13
    Registered User
    Join Date
    11-29-2010
    Location
    North Carolina
    MS-Off Ver
    Excel 97 thru Excel 2010
    Posts
    12

    Re: Excel 97 macro error

    I added "Range("A1").select" to make sure only one cell was selected as romperstomper pointed out in shg's post and it works fine now. Also re-installed 2010 with VBA. Thanks to you both!

    src

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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