+ Reply to Thread
Results 1 to 6 of 6

Method 'range' of object'_Global' failed

  1. #1
    Registered User
    Join Date
    06-17-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    5

    Method 'range' of object'_Global' failed

    Dear all,

    I really have no programming knowledge at all and this is what I figured out so far.

    1) I'm suppose to create a form (quite a long one)
    2) I've created a 'reset' button to reset an entry fields
    3) When the button is click, a warning box suppose to pop up
    3) while indicating the cells which I want to 'clear content' this error occurs.
    4) I'm trying the range bit by bit and I've encounter this problem at the 7th set.

    The command is as follows:

    Sub Clearcontent()

    lReply = MsgBox("Are you sure?", vbOKCancel)

    If lReply = vbCancel Then Exit Sub

    ActiveSheet.Range("D13:D15,E13:E15,C16,B17,C18,B19,D20,B21,D24:D27,E24:E27,C28,B29,C30,B31,D32,B33,D36:D42,E36:E42,C43,B44,C45,B46,D47,B48,D51:D56,E51:E56,C57,B58,C59,B60,D61,B62,D65:D94,E65:E94,C95,B96,C97,B98,D99,B100,D104:D109,E104:E109,C110,B111,C112,B113,D114,B115,D118:D129,E118:E129,C130,B131,C132,B133,D134,B135") = ""
    End Sub

    The error only show up when I enter this range: D118:D129,E118:E129,C130,B131,C132,B133,D134,B135

    Please advised =)

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Method 'range' of object'_Global' failed

    Make a complete reference

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-17-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Method 'range' of object'_Global' failed

    I tried your code but there is still some error. May I ask is it okay to input all the range
    "D13:D15,E13:E15,C16,B17,C18,B19,D20,B21,D24:D27,E24:E27,C28,B29,C30,B31,D32,B33,D 36:D42,E36:E42,C43,B44,C45,B46,D47,B48,D51:D56,E51:E56,C57,B58,C59,B60,D61,B62,D65:D94,E65:E94,C95,B 96,C97,B98,D99,B100,D104:D109,E104:E109,C110,B111,C112,B113,D114,B115,D118:D129,E118:E129,C130,B131, C132,B133,D134,B135" in one long code?

    Is there a way to break it up?

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Method 'range' of object'_Global' failed

    Maybe there is a limit to non contiguous cells.
    Test that by starting with 2 cells and check whether it generates errors.

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,265

    Re: Method 'range' of object'_Global' failed

    You are limited to using 255 characters in the address. You are trying to use 303. You will have to break it up into two sections using Union:
    Please Login or Register  to view this content.
    for example.
    Remember what the dormouse said
    Feed your head

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Method 'range' of object'_Global' failed

    or reduce the length of the address by using contiguous ranges where viable (eg D36:E42 rather than D36:D42,E36:E42)

    Please Login or Register  to view this content.

+ 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