+ Reply to Thread
Results 1 to 8 of 8

ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

  1. #1
    Registered User
    Join Date
    01-06-2015
    Location
    Pacific Northwest
    MS-Off Ver
    2010
    Posts
    38

    ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Hi All,
    I have a Userform that sucessfully populates a pair of Source Combo Boxes and a pair of Target Combo Boxes with open Workbook and Worksheet names that I am having trouble using in a VBA formulas.

    cboSourceBook, cboSourceSheet, cboTargetBook and cboTargetSheet are the names of the properly populated combo boxes.
    The SetSourceWorkbook .... Line generates a Run-time error '424': Object Required error.

    Please Login or Register  to view this content.
    This code works as a macro but I wanted to set the Source and Target Workbooks and Worksheets with the values in the Combo Boxes and not have to use the "Workbooks.Open" and drop the "SourceWorkbook.Close" statements.

    Please Login or Register  to view this content.
    Been trying many options to understand why cboSourceBook.Value isn't an Object but I'm lost.

    TIA
    Bud
    Last edited by Bud Wilkinson; 01-08-2015 at 10:57 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    You're not assigning any objects, just values.

    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    01-06-2015
    Location
    Pacific Northwest
    MS-Off Ver
    2010
    Posts
    38

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Tinbender,
    Thanks for that. It has me halfway home it would seem. Now the trouble is that the cboTargetBook.Value and cboTargetSheet.Value are giving me errors.
    When set the same way as the source the Workbook statement gives a Run-time error 9 Subscript Out of Range.
    When used as follows it works fine but I would like for the Target to be selected from the Combo Boxes as well.

    Please Login or Register  to view this content.
    Thanks,
    Bud

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Are both workbooks open? The Target and Source?

    If so, then you could iterate the workbook collections and add the correct wb names/sheet names to the combobox.

  5. #5
    Registered User
    Join Date
    01-06-2015
    Location
    Pacific Northwest
    MS-Off Ver
    2010
    Posts
    38

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Quote Originally Posted by Tinbendr View Post
    Are both workbooks open? The Target and Source?

    If so, then you could iterate the workbook collections and add the correct wb names/sheet names to the combobox.
    Tinbendr,
    Yes both Workbooks are open.
    Sorry to be such a Noob but I'm not sure what is meant by "iterate the workbook collection".
    There is a userform that has a frame containing two combo boxes that are Source and another frame with two combo boxes that are Target. the top combo box in each frame is for workbook and the bottom is for choosing the worksheets from the drop down list of the chosen book.

    The one thing with the routine of filling the comboboxes for the Target is that it adds some info and looks like "This Book (~Open Workbook File Name.xlsm)" "This Sheet (~Sheet Name)" to denote the book and sheet the form was launched from. It looks like this.

    UserForm02.jpg

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    but I'm not sure what is meant by "iterate the workbook collection".
    Excel stores many things in collections. All the workbooks that are open as in a collection. All the shapes on a sheet are a collection. And so on. You can iterate (loop through) these collections looking for information.

    But after seeing your snapshot of the frame, I'm even more confused about the flow of the operation. Can you describe how you fill the comboboxes?

    Is this code in either of the Target or Source workbooks? If so, then you don't need to put the filename in a dropdown since there is only one selection. You can however, put the sheet names in a combobox. But even this is moot if you copying and pasting from a named range. (I realize that this may be part of an exercise for you, but it's really redundant.)

    The tilde (~) is a symbol Office uses to indicate the current open file. It's like a temp file and you don't want to use that as a filename.

  7. #7
    Registered User
    Join Date
    01-06-2015
    Location
    Pacific Northwest
    MS-Off Ver
    2010
    Posts
    38

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Tinbender,
    Thanks for the help so far, Sorry to take so long to get back to you......Life.....
    Below is the code that populates the Target and Source combo boxes. It was copied and adapted from a different form so I am not positive how it works. I am wondering if the "This Sheet" statement in the target selections could be causing the problem. I realize the using the combo box for the target selections is redundant but there may be incidents where I wish to import the same named values to other open books/sheets at the same time before the mind slips and forgets to do it.
    I have probably used inappropriately the tilde as a space saver in examples and not in the actual code.

    Please Login or Register  to view this content.
    Thanks,
    Bud

  8. #8
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: ComboBox Value to use in VBA formula gets Run-time error 424 Object Required

    Yes, the 'This Book' and 'This Sheet' are the culprits. You'll have to test for and strip the phrases before setting the object.

    This makes this macro really complicated.

    I went against my principles and recreated the workbook. See attached.

+ 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. Object Required Run time error 424
    By rjayaram.rj in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-26-2014, 11:22 AM
  2. [SOLVED] Simple Calendar pop up macro --> error Run-time error '424': Object required
    By am_hawk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2013, 10:38 AM
  3. Run-time error 424.. object required
    By techteam in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2012, 07:01 AM
  4. Run-time error '424': Object Required
    By ElmerFuddy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2009, 05:30 PM
  5. Run Time error 424 Object Required
    By Casey in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-12-2006, 02:51 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