+ Reply to Thread
Results 1 to 10 of 10

ERROR with set range

  1. #1
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    ERROR with set range

    What is wrong in this code?

    Please Login or Register  to view this content.

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

    Re: ERROR with set range

    Either

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: ERROR with set range

    nothing wrong with that part, the error is with ws.rng.Select

  4. #4
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: ERROR with set range

    error:
    "Method or data member not found"
    Last edited by JJGF; 06-14-2016 at 02:28 PM.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ERROR with set range

    It should just be rng.Select but that will also fail unless ws is active.

    What do you want to do with the range? It's seldom, if ever, needed to select a range to work with it.
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: ERROR with set range

    Quote Originally Posted by Norie View Post
    It should just be rng.Select but that will also fail unless ws is active.

    What do you want to do with the range? It's seldom, if ever, needed to select a range to work with it.
    ok, what I really want to know is why does ws.Range("A1:J" & lr).Select work but ws.rng.Select does not.
    I thought rng represents Range("A1:J" & lr).

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

    Re: ERROR with set range

    Yes, it is one of the strange behavior of VBA

    Please Login or Register  to view this content.
    Last edited by AB33; 06-14-2016 at 02:38 PM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: ERROR with set range

    The range rng is not a property or method of the worksheet ws, it's an object variable that refers to a range on ws and it's parent is the worksheet ws.

  9. #9
    Forum Contributor
    Join Date
    12-06-2012
    Location
    sacramento,calif
    MS-Off Ver
    Excel 2010
    Posts
    217

    Re: ERROR with set range

    ok, thanks for all the replies, I have to be away for next 10 hours.

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

    Re: ERROR with set range

    Norie,
    If ws is the parent of a range, should the sibling inherit its properties from its ancestor.? Or Inheritance does not work in VBA

+ 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. Runtime error '1004': Paste special method of range class error.
    By Daryl Zer0 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-05-2014, 01:44 AM
  2. [SOLVED] Error checking routine - check range values on various worksheets and report if error
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-29-2014, 06:36 AM
  3. [SOLVED] Run-time error '9': subscript out of range - error occurs on multiple computers except one
    By BrettE in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-06-2014, 11:19 PM
  4. Replies: 4
    Last Post: 11-15-2013, 05:03 PM
  5. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  6. [SOLVED] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  7. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 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