+ Reply to Thread
Results 1 to 7 of 7

Sub Not Defined error with CopyPaste macro

  1. #1
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    Office365
    Posts
    58

    Sub Not Defined error with CopyPaste macro

    Need help with this macro please...
    Need to copy selected columns from one sheet and past to another another.
    This code gives me a "sub not defined" error.

    Please Login or Register  to view this content.
    Appreciate any help.
    Thanks
    Rob

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Sub Not Defined error with CopyPaste macro

    Hi,

    Are you sure it's not a "variable not defined" error? You haven't declared i but otherwise that code is fine.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Sub Not Defined error with CopyPaste macro

    The only bigger issue (but variable declaration - which is anyway optional) is that you try to
    Please Login or Register  to view this content.
    Of course if other sheet is active at the moment the code will fail here. But the error message will be different than you've shown.

    PS. I'd rather avoid naming variables sheet1 and sheet2 - these are standard objects names and can be reused, but it's a good practice not to do so.
    Best Regards,

    Kaper

  4. #4
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    Office365
    Posts
    58

    Re: Sub Not Defined error with CopyPaste macro

    The error I get is "Sub or Function not defined"

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Sub Not Defined error with CopyPaste macro

    There is nothing in the code you posted that should cause that as the syntax is fine and doesn’t call any other routines. Is there other code in the same workbook?

  6. #6
    Registered User
    Join Date
    06-03-2014
    MS-Off Ver
    Office365
    Posts
    58

    Re: Sub Not Defined error with CopyPaste macro

    I should start fresh..
    Need code to do the following:

    Worksheets ("Data") contains raw data
    Worksheets ("Summary") will process some of the data taken from the ("Data") sheet. That data is in several columns down to the last entry.
    Need to copy those column ranges to the ("Summary") sheet.

    Thanks
    Rob

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Sub Not Defined error with CopyPaste macro

    As for #6:
    Will you please attach a SMALL sample Excel workbook(s) (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. (If trere are typical cases like: all unique values/duplicates could occur, day/night, nobody present/several persons at once, before/on/past due, etc. - please show them all or at least indicate in text) The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution(s) is/are also shown (mock up the results manually).

    3. Make sure that all confidential/restricted information (either personal or business) like real e-mails, social security numbers, bank accounts, etc. is removed first!!

    To attach an Excel file you have to do the following: Just before posting, scroll down and press Go Advanced button and then scroll down and press Manage Attachments link. Now follow the instructions at the top of that pop-up screen.

    As for post #4 - which line is highlighted in yellow, when your code execution is stopped and you press Debug (see also above comments on attachment(s))

+ 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. excel macro run time error '1004'- Application defined or object defined error
    By kmadan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2014, 09:51 AM
  2. [SOLVED] Macro Error 1004 Application Defined or object defined error. PLEASE HELP
    By balston2 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2012, 10:29 AM
  3. [SOLVED] Macro causes Run time error 1004 Application defined or object-defined error
    By Firefighter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2012, 04:09 AM
  4. Error 1004: macro application-defined or object-defined error
    By TMI Trading in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2012, 08:35 PM
  5. [SOLVED] Macro error - Run time error 1004 (App defined/Object Defined error)
    By jlax34 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2012, 03:02 PM
  6. Macro - Run-time Error '1004': Application defined or object defined error
    By robby10 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-14-2010, 07:55 AM
  7. Error Generation during copypaste macro run
    By ravinder_tigh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2009, 01:00 AM

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