+ Reply to Thread
Results 1 to 3 of 3

Two ranges good separatly but not together

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Two ranges good separatly but not together

    XL2010
    I've successfully done this with numerous other workbooks but not these two.

    Runtime error 1004
    wbThis.Worksheets("Sheet1").Range(Cells(LastRowORD, 1), Cells(LastRowORD, LastCol)).Value = wbCSV.Worksheets("Sheet1").Range(Cells(i, 1), Cells(i, LastCol)).Value
    The Range is valid because
    in the immediate pane with EACH RESPECTIVE WORKBOOK ACTIVE
    I can successfully select each half in this manner:
    wbThis.Worksheets("Sheet1").Range(Cells(LastRowORD, 1), Cells(LastRowORD, LastCol)).select
    wbCSV.Worksheets("Sheet1").Range(Cells(i, 1), Cells(i, LastCol)).select

  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: Two ranges good separatly but not together

    Hi,

    You must qualify the Cells properties with the same worksheet object as the Range property
    wbThis.Worksheets("Sheet1").Range(wbThis.Worksheets("Sheet1").Cells(LastRowORD, 1), wbThis.Worksheets("Sheet1").Cells(LastRowORD, LastCol)).Value = wbCSV.Worksheets("Sheet1").Range(Cells(i, 1), Cells(i, LastCol)).Value
    Using a With block or a variable would be tidier.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Contributor
    Join Date
    08-14-2006
    Location
    USA
    MS-Off Ver
    2019
    Posts
    686

    Re: Two ranges good separatly but not together

    THANK YOU!
    I took all my variables out in case they were causing the problem.
    In the past I have used Named Ranges (with Workbook scope) to enter values, which eliminated the need for the seemingly redundant qualifying.

+ 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. Creating 'Network IP' and 'Subnet IP' Ranges from IP CIDR subnets ranges
    By sokolum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2019, 06:46 AM
  2. [SOLVED] Find and bring product code separatly in another coloumn
    By 30051980 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-08-2017, 03:45 AM
  3. Extracting Numbers and alphanumerics separatly from a cell
    By BALA1983 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-20-2017, 10:06 PM
  4. Replies: 11
    Last Post: 06-30-2016, 07:07 PM
  5. Open Excel separatly
    By Marianus in forum Excel General
    Replies: 3
    Last Post: 10-28-2013, 02:09 PM
  6. Replies: 0
    Last Post: 10-15-2012, 07:24 AM
  7. Copy data in named ranges to a newer version of the same template to identical ranges
    By handstand in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-21-2006, 10:51 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