+ Reply to Thread
Results 1 to 9 of 9

Copy data from workbook selected in combobox (recieving object error)

  1. #1
    Registered User
    Join Date
    12-18-2016
    Location
    Utah, United States
    MS-Off Ver
    2016
    Posts
    7

    Copy data from workbook selected in combobox (recieving object error)

    I am trying to have my Workbook copy the data from another workbook. The workbook to copy data from is based on the selection from combobox1, which lists all open workbooks. After the selection is made, my macro to copy data will run.

    When I run the macro, it opens the combo box and I select the data I want copied and click “OK”. After I click “OK”, it runs the sub named “ClearandPullStatsinArray1”. However, I get a “no object defined” error when it is running this sub.

    I cannot figure out why. Screenshot below. Thank you for your help!

    USER FORM:

    Please Login or Register  to view this content.

    IN ANOTHER MODULE:

    Please Login or Register  to view this content.
    Attached Images Attached Images

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Copy data from workbook selected in combobox (recieving object error)

    Try

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

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    12-18-2016
    Location
    Utah, United States
    MS-Off Ver
    2016
    Posts
    7

    Re: Copy data from workbook selected in combobox (recieving object error)

    I tried that and got the error "Invalid attribute in Sub or Function" and it highlighted the word "Public" in the "ClearandPullStatsInArray1".

    Please Login or Register  to view this content.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Copy data from workbook selected in combobox (recieving object error)

    Also need to change at the top of your code. Remove Public MyFile as Workbook from inside of your Sub ClearAndPullNewStatsInArray1

    From
    Please Login or Register  to view this content.
    To
    Please Login or Register  to view this content.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Copy data from workbook selected in combobox (recieving object error)

    Like this

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-18-2016
    Location
    Utah, United States
    MS-Off Ver
    2016
    Posts
    7

    Re: Copy data from workbook selected in combobox (recieving object error)

    Thank you for responding so quickly! I am new to VBA and I am still learning.

    After I followed your steps above, it seemed to resolve the error in my "ClearandPullStatsInArray1" sub.

    But now I have an error in my UserForm. It highlighted my code "MyFile = Me.ComboBox1.Value", and gave me the error "Object Variable or With Block Variable Not set".

    Do you know what that could fix that?

    Please Login or Register  to view this content.
    Last edited by cadams; 01-06-2017 at 08:59 PM.

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Copy data from workbook selected in combobox (recieving object error)

    Not sure what you are trying to do in the CommandButon1.Click. You are closing the form? But same as the other. If you are setting the Workbook object with the Variable MyFile need to use Workbooks(.....)

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    12-18-2016
    Location
    Utah, United States
    MS-Off Ver
    2016
    Posts
    7

    Re: Copy data from workbook selected in combobox (recieving object error)

    I do not have any experience with userforms or combo boxes so I got my code for the Userform from this thread here. Does this help? Could you suggest some code to use if this is wrong for what I want.

  9. #9
    Registered User
    Join Date
    12-18-2016
    Location
    Utah, United States
    MS-Off Ver
    2016
    Posts
    7

    Re: Copy data from workbook selected in combobox (recieving object error)

    I have figured it out. Thank you for your help Mike!

+ 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] Copy data from workbook selected in combo box "object error"
    By cadams in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2017, 08:32 PM
  2. [SOLVED] Object variable error with combobox
    By ajam in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-17-2016, 02:13 PM
  3. [SOLVED] Copy selected data from one workbook to another
    By sjm.sonu82 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-22-2015, 09:14 AM
  4. ComboBox Value to use in VBA formula gets Run-time error 424 Object Required
    By Bud Wilkinson in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-15-2015, 10:34 PM
  5. Recieving the error "the object invoked has disconnected from its clients"
    By chidmas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-13-2013, 07:52 AM
  6. Open Workbook .Copy to Wb Causes Object Error 424
    By iamafiqing in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2013, 08:41 PM
  7. Copy selected data to Workbook on Desktop
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2009, 11:17 AM

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