+ Reply to Thread
Results 1 to 7 of 7

Why am I getting an application-based/object-based error?

Hybrid View

aloha31 Why am I getting an... 07-16-2013, 05:27 PM
AB33 Re: Why am I getting an... 07-16-2013, 05:33 PM
AB33 Re: Why am I getting an... 07-16-2013, 05:34 PM
JosephP Re: Why am I getting an... 07-16-2013, 05:36 PM
aloha31 Re: Why am I getting an... 07-16-2013, 05:45 PM
AB33 Re: Why am I getting an... 07-16-2013, 05:49 PM
JosephP Re: Why am I getting an... 07-16-2013, 05:51 PM
  1. #1
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Post Why am I getting an application-based/object-based error?

         ActiveWorkbook.Worksheets("Line 70").Range("C4", Range("D" & Rows.Count).End(xlUp)).Copy _
                Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T1" & Rows.Count).End(xlUp).Offset(1)
         ActiveWorkbook.Worksheets("Line 76").Range("C4", Range("D" & Rows.Count).End(xlUp)).Copy _
                Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T1" & Rows.Count).End(xlUp).Offset(1)
    Not sure if I need to define something or if my formatting is just wrong. All I am trying to do is copy columns from two worksheets into one main worksheet.

    Please help!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Why am I getting an application-based/object-based error?

    With out 1

    ActiveWorkbook.Worksheets("Line 70").Range("C4", Range("D" & Rows.Count).End(xlUp)).Copy _
                ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)
         ActiveWorkbook.Worksheets("Line 76").Range("C4", Range("D" & Rows.Count).End(xlUp)).Copy _
                ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Why am I getting an application-based/object-based error?

    More likely

    ActiveWorkbook.Worksheets("Line 70").Range("C4:C", Range("D" & Rows.Count).End(xlUp)).Copy _
                ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)
         ActiveWorkbook.Worksheets("Line 76").Range("C4:C", Range("D" & Rows.Count).End(xlUp)).Copy _
                ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Why am I getting an application-based/object-based error?

    you need to qualify all the ranges

       with ActiveWorkbook.Worksheets("Line 70")
        .Range("C4", .Range("D" & .Rows.Count).End(xlUp)).Copy _
                Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T1" & Rows.Count).End(xlUp).Offset(1)
    end with
        with ActiveWorkbook.Worksheets("Line 76")
          .Range("C4", .Range("D" & .Rows.Count).End(xlUp)).Copy _
                Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T1" & Rows.Count).End(xlUp).Offset(1)
    end with
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Contributor
    Join Date
    07-12-2013
    Location
    Los angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    109

    Re: Why am I getting an application-based/object-based error?

    Thank you both, the answer was actually a combination of both of your responses:
    With ActiveWorkbook.Worksheets("Line 70")
        .Range("C4", .Range("D" & .Rows.Count).End(xlUp)).Copy _
            Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)
    End With
    With ActiveWorkbook.Worksheets("Line 76")
        .Range("C4", .Range("D" & .Rows.Count).End(xlUp)).Copy _
            Destination:=ActiveWorkbook.Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)
    End With

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Why am I getting an application-based/object-based error?

    Yes with and end with is more accurate, but IF all the sheets are on the same workbook, this should also work.

    Worksheets("Line 70").Range("C4:C", Range("D" & Rows.Count).End(xlUp)).Copy _
            Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)
         Worksheets("Line 76").Range("C4:C", Range("D" & Rows.Count).End(xlUp)).Copy _
        Worksheets("Working Total DX Departures").Range("T" & Rows.Count).End(xlUp).Offset(1)

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Why am I getting an application-based/object-based error?

    no because
    Range("D" & Rows.Count).End(xlUp)
    will find the last used row in column D on the active sheet, not the required sheet (it's also missing the .Row part)

+ 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] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 PM
  2. 1004 Error - Application or object defined error
    By davidman1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-27-2013, 10:53 AM
  3. [SOLVED] 1004 Error - Application or object defined error
    By davidman1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2013, 11:29 AM
  4. [SOLVED] Error 1004, Application-definded or object-defined error
    By Mirco Wilhelm in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-07-2006, 01:00 PM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By rich5665@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05:05 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