Results 1 to 4 of 4

using cells to define range gives run time error

Threaded View

  1. #1
    Registered User
    Join Date
    02-05-2010
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003
    Posts
    3

    using cells to define range gives run time error

    I run a macro with the following code:

        Dim myArray() As Variant
        myArray = Worksheets("name1").Range("A1:B1").Value
        Worksheets("name2").Range("A1:B1").Value = myArray
    And it works fine, copying the cells from name1 to name2.

    If I replace the code with this:

        Dim myarray() As Variant
        myarray = Worksheets("name1").Range(Cells(1, 1), Cells(1, 2)).Value
        Worksheets("name2").Range(Cells(1, 1), Cells(1, 2)).Value = myarray
    I get Run time error 1004: Application defined or object defined error

    Why?

    Many thanks!
    Last edited by dudamel; 02-05-2010 at 01:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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