+ Reply to Thread
Results 1 to 3 of 3

error 1004 Method 'Range' of object '_Worksheet' failed when selecting multiple ranges

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    11

    error 1004 Method 'Range' of object '_Worksheet' failed when selecting multiple ranges

    Hi,

    I have a problem with my vba code. I have two similar codes, only the ranges are different. But for the first range excel will not give an error. And for the second range excel give this error:
    run-time error '1004':
    Method 'Range' of object '_Worksheet' failed.

    I don't understand thisbecause both ranges are containing as much multiple ranges in it. The only different is that the first range contains less caracters because a range is like R7:AC7 and the second range is like AG7:AR7.

    Can anyone help me with this?

    Thanks a lot.

    This codes works
    Please Login or Register  to view this content.
    same code with this range instead doesn't works:
    Sheet11.Range("AG7:AR7,AG22:AR22,AG37:AR37,AG52:AR52,AG67:AR67,AG82:AR82,AG97:AR97,AG112:AR112,AG127:AR127,AG142:AR142,AG157:AR157,AG172:AR172,AG187:AR187,AG202:AR202,AG217:AR217,AG232:AR232,AG247:AR247,AG262:AR262,AG277:AR277,AG292:AR292,AG307:AR307,AG322:AR322,AG337:AR337,AG352:AR352").SpecialCells(xlCellTypeBlanks).Cells(1).Select

    When I choose debug this range is selected in yellow.

    Kind regards,
    Last edited by Edejager; 04-25-2013 at 07:51 AM.

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

    Re: error 1004 Method 'Range' of object '_Worksheet' failed when selecting multiple ranges

    the string that you pass to Range can only be 255 characters in length-I haven't checked but I reckon the second one is too long
    Josie

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

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: error 1004 Method 'Range' of object '_Worksheet' failed when selecting multiple ranges

    Thanks,

    That's the problem. It counts 274 characters(didn't count it by hand .
    I didn't know how many characters a range can be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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