+ Reply to Thread
Results 1 to 3 of 3

Range Select with ActiveCell and Offset property

Hybrid View

  1. #1
    Registered User
    Join Date
    07-28-2004
    Posts
    9

    Range Select with ActiveCell and Offset property

    I need to clear the contents of a certain range and yes I could just write the code as follows: Range("a1:b240").clearcontents

    however, the range selection depends on the active cell. I have tried entering the following: Range(activecell, activecell.offset(1,240)).clearcontents
    But I keep receiving a runtime error '1004'. Any ideas on how to fix this? Thanks....AJ

  2. #2
    Jim Thomlinson
    Guest

    RE: Range Select with ActiveCell and Offset property

    There are only 256 columns (unless you are beta testing the new XL). You are
    offsetting by 256 columns, which means there is a good possibility that you
    are offsetting right off the end of the sheet, which would generate that
    error.
    --
    HTH...

    Jim Thomlinson


    "AJ Master" wrote:

    >
    > I need to clear the contents of a certain range and yes I could just
    > write the code as follows: Range("a1:b240").clearcontents
    >
    > however, the range selection depends on the active cell. I have tried
    > entering the following: Range(activecell,
    > activecell.offset(1,240)).clearcontents
    > But I keep receiving a runtime error '1004'. Any ideas on how to fix
    > this? Thanks....AJ
    >
    >
    > --
    > AJ Master
    > ------------------------------------------------------------------------
    > AJ Master's Profile: http://www.excelforum.com/member.php...o&userid=12386
    > View this thread: http://www.excelforum.com/showthread...hreadid=553838
    >
    >


  3. #3
    Registered User
    Join Date
    07-28-2004
    Posts
    9
    Jim

    Thanks.....you were quite right. It should have been (240,1) and not (1,240). I think the brains had too much VBA today. Thanks...again! ...AJ

+ 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