+ Reply to Thread
Results 1 to 8 of 8

Compile Error : Object required in VBA code

  1. #1
    Registered User
    Join Date
    06-28-2017
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    24

    Compile Error : Object required in VBA code

    So i have two ranges, on my "Home Page" sheet, that each contains a drop down list.

    Each Drop Down List contains the same list of sheets ( "Location 1","Location 2",...)

    EXCEL DROP DOWN.PNG

    All the "Location #" sheets have the same layout.

    I have a CommandButton1 on my "Home Page" Sheet aswell.

    I would like to be able to Copy/Paste from a sheet to another while staying on the home page.

    But I'm getting a Compile Error : Object Required

    EXCEL OBJ REQU.PNG

    Here is my code, any help is appreciated.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Compile Error : Object required in VBA code

    SheetCopy as you have it is a Range not a String

    Please Login or Register  to view this content.
    I haven't looked at the rest of your code as you are using merged cells.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,012

    Re: Compile Error : Object required in VBA code

    Don't use Set - that is only for when you are using an object-based variable. You are using a string (and merged cells!), so just use

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    06-28-2017
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    24

    Re: Compile Error : Object required in VBA code

    Alright thanks guys!! I've got passed that Error, now I'm getting Subscript out of range error.

    Its when i'm trying to Dim WScopy as a worksheet variable.

    Please Login or Register  to view this content.
    Thanks for your times guys

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Compile Error : Object required in VBA code

    You don't have a sheet named 'SheetCopy' ...

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,012

    Re: Compile Error : Object required in VBA code

    You need to use Set in that case (now you are using an object), and lose the quotes since you have a variable:

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Compile Error : Object required in VBA code

    I suspect you want it as below (which is what Bernie Deitrick posted originally)

    Leave it as a String and make the change Bernie Deitrick posted in post #3 and remove the quotes.


    Please Login or Register  to view this content.
    Btw, I don't know why you aren't just doing
    Please Login or Register  to view this content.
    rather than use the sheetcopy variable
    Last edited by WasWodge; 06-28-2017 at 11:42 AM. Reason: added last line

  8. #8
    Registered User
    Join Date
    06-28-2017
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    24

    Re: Compile Error : Object required in VBA code

    Yes WasWodge and Bernie, you guys figured it out.

    Thanks alot!!

    here is my functional code and layout for future references if any other are trying to do the same thing.

    DONECompost Pile Manager.PNG

    Please Login or Register  to view this content.
    GL HF

+ 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. Replies: 5
    Last Post: 05-19-2016, 04:34 AM
  2. Compile Error - Object Required when opening Userform on another PC
    By Scoobymoo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2015, 05:48 AM
  3. [SOLVED] Why 'object required' error from this code?
    By vizzkid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-18-2013, 09:35 AM
  4. Compile error: Object required
    By Hinnerk in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-23-2012, 04:38 PM
  5. Compile error : object required in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2010, 04:08 AM
  6. Error 424 Object Required Error when Using AddItem to ListBox Generated in Code
    By jclark419 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2010, 12:47 PM
  7. VBA Help needed -- compile error: object required
    By alexandraVBAgirl in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-17-2006, 09:00 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