+ Reply to Thread
Results 1 to 7 of 7

Error 1004 and 424 upon workbook open

  1. #1
    Registered User
    Join Date
    06-06-2011
    Location
    cleveland, ohio
    MS-Off Ver
    Excel 2010
    Posts
    4

    Error 1004 and 424 upon workbook open

    I am creating a group of interactive excel forms
    They are all in one workbook, there are many VBA objects on each sheet
    These objects change which other objects are displayed, which rows are visible / hidden (via named ranges scoped to worksheet), values of cells (via named ranges scoped to worksheet)
    The results may also depend upon the values of other objects in conjunction with their own value.

    I want the sheets to be able to be filled out and saved
    I need to be able to copy the sheets to duplicate the form within the same workbook as necessary
    I also need to be able to insert rows as necessary without causing error

    In the code I am only using named ranges scoped to each worksheet to facilitate this

    The only named ranges scoped to the workbook are ones which fill list boxes


    I get this error whenever I open the workbook and there are any values set for the objects

    Run-time error ‘1004’:
    Selected method of Range class failed

    Here is a sample section of code where I get an error

    Please Login or Register  to view this content.
    The error occurs where the named ranges come in “SFRACLabel…”

    I also have the same type of code for many other commands such as changing borders, protection, hidden property, and value

    When the sheet which the code is assigned to is selected and the workbook is saved, that part of the code runs fine

    Then I get an error
    Error 424 : Object Required



    Please Login or Register  to view this content.
    the error highlights “If ComboBox5.Text = "3 Tier" ”


    Some of the sheets have the same object names


    This workbook works fine once it is open


    Solution A. is there any way to stop excel from running this code at open and only run at an action (e.g. my code is under ComboBox#_Change shouldn’t it only be run/read when the combobox is changed?)

    Solution B. is there any way to activate each sheet and allow the code to run for that sheet
    (I tried using a FOR loop already in the workbook open section to sequentially activate each sheet and it didn’t change anything)

    My file is hosted here
    http://www.box.net/shared/161yzmqdlf

    Any help would be appreciated.

    Thanks,
    JJohanni

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Error 1004 and 424 upon workbook open

    OK, one at a time...Select Method of Range class failed.

    Are you sure the sheet is unprotected and all the four SFRAC range names are on the same sheet? What does 'UnlockSheet' actually do?

    Do you really need to Select anyway. Have you tried just

    Please Login or Register  to view this content.
    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-06-2011
    Location
    cleveland, ohio
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Error 1004 and 424 upon workbook open

    Thank you very much for the quick reply

    This is the code for protecting and unprotecting the sheet

    Please Login or Register  to view this content.
    so yes the sheet is unprotected

    and your recommended command seems to work for clearing contents but i still had problems with other commands

    it seems to be fixed now however
    i added

    Please Login or Register  to view this content.
    before the main code for each ComboBox_Change

    but i still have the problem with the 424 error

    the numbering pattern of the comboboxes is the same where the error occurs
    the number of the combobox with the code is one less that the one which is referenced throught the if statement

    does excel load them in order one at a time
    and run the code before loading the next one?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Error 1004 and 424 upon workbook open

    Hi,

    Can you explain " I get this error whenever I open the workbook and there are any values set for the objects". What do you mean by values and objects?

    Do you have any code in the Workbook Open event? Unless you do I can't see why any macro would automatically run when you open the workbook.

    There are of course Sheet Activate, Sheet Change and Sheet Selection Change events, which can all trigger macros. It all depends when you want them to be triggered.

    Regards

  5. #5
    Registered User
    Join Date
    06-06-2011
    Location
    cleveland, ohio
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Error 1004 and 424 upon workbook open

    By objects i mean VBA objects or controls e.g. combobox
    by value i mean the value property of the object

    so I have a combobox set up as a list box with a user specified value

    before anything is selected it has value of ""
    after something is selected the value changes

    I don't have anything in the workbook open event

    I dont have any sheet events either

    the only event that is triggering is the ComboBox_Change event
    and that is when i get the error

    This only occurs when something was selected from the combobox list and the workbook saved
    the error occurs upon re-opening


    Thanks again

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Error 1004 and 424 upon workbook open

    Hi,

    Are you able to upload the workbook, anonymised if necessary.

    Regards

  7. #7
    Registered User
    Join Date
    06-06-2011
    Location
    cleveland, ohio
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Error 1004 and 424 upon workbook open

    Here it is

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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