+ Reply to Thread
Results 1 to 6 of 6

Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

  1. #1
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    I have two questions:
    ------------------------------------------------------------------------------
    ------------------------------------------------------------------------------
    1: I would like to know why the following code fails at line: Set wsd.Cells.UsedRange = rng.Cells with runtime error 438.
    --I've tried many combinations of wsd.Cells = rng.Cells, wsd.Cells.Value = rng.Cells.Value, wsd.Cells(rng.Address).Value = rng.Cells.Value, wsd.Cells(rng.Address) = rng.Cells,...
    --I would like to avoid a For-Each loop.
    -The goal I'm trying to accomplish is copy cells from one worksheet to another without using the wss.Copy method. Is that possible?
    ------------------------------------------------------------------------------
    2: How can I accomplish my goal?
    ------------------------------------------------------------------------------
    Please Login or Register  to view this content.
    Any help is appreciated. I've seen a similar question posted in the forum, but the author lost interest in solving this problem.

    PS ...ok I can see how the .UsedRange method would not be used in:
    wsd.Cells (especially if there is no Used range in the destination worksheet but I'm still struggling with this when I drop the "UsedRange").
    Last edited by joe31623; 01-14-2016 at 01:46 PM.
    <---If my answer helped, please click *

  2. #2
    Valued Forum Contributor Gatti's Avatar
    Join Date
    06-08-2015
    Location
    Brasil, São Paulo, Ribeirão Preto
    MS-Off Ver
    365
    Posts
    346

    Re: Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    Set is for declare an object value or refference

    Remove the Set and try again

  3. #3
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    Gatti,

    Thanks for the attempt.

    Without the Set, I continue to get Error 438: Object doesn't support this property or method.

  4. #4
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    Usedrange is property of worksheet. Also is read-only.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  5. #5
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    ...Interesting -- I get a not enough memory error when I use line:
    wsd.Cells = rng.Cells, which makes sense b/c excel is trying to use ALL cells in the destination workbook.

    ...so when I run the code by replacing the line that is giving me an error with:
    wsd.Range(rng.Address) = rng.Cells, I get no error!

    So because I'm after the values, I replace the line with:

    wsd.Range(rng.Address).Value = rng.Cells.Value and it WORKS!!!

  6. #6
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Why doesn't this method work: {Set wsd.Cells.UsedRange = rng.Cells} ?

    Here is my corrected code that accomplishes what I was trying to do:
    Copy cells onto another worksheet in another workbook w/o using the copy method:

    Please Login or Register  to view this content.
    Thank you Izandol and Gatti for helping!
    Last edited by joe31623; 01-14-2016 at 01:56 PM.

+ 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] usedrange doesn't reset when using 'application.activesheet.usedrange'
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2015, 10:39 PM
  2. [SOLVED] Would like to do lastrow = activecolumn.usedrange.rows.count but it doesn't work
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2014, 04:19 PM
  3. Replies: 1
    Last Post: 11-09-2013, 02:43 AM
  4. Code with Range(Cells()) doesn't work. Why?
    By seigna in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 04-21-2013, 04:04 PM
  5. Formula doesn't work in some cells
    By mateoc15 in forum Excel General
    Replies: 2
    Last Post: 04-27-2010, 01:04 PM
  6. Why QUIT method doesn't work after COPY method?
    By surotkin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2005, 11:32 AM
  7. BreakLinks method doesn't work.
    By Gop in forum Excel General
    Replies: 0
    Last Post: 09-01-2005, 07:27 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