+ Reply to Thread
Results 1 to 3 of 3

Clear Contents won't work on merged cells

  1. #1
    ArthurJ
    Guest

    Clear Contents won't work on merged cells

    I have merged cells C1 and D1, and named it 'mergedCells'.
    But I get a "400" error from the following VBA code:

    [mergedCells].ClearContents

    That seems odd. Is there a workaround?

    Art

  2. #2
    JNW
    Guest

    RE: Clear Contents won't work on merged cells

    You have to reference all of the cells that are merged. In your example the
    following should work...

    Range("C1:D1").clearcontents

    It's not enough to reference the first of the merged cells (which is
    bothersome because in other instances, like copy, you can reference the first
    of the merged cells only)

    "ArthurJ" wrote:

    > I have merged cells C1 and D1, and named it 'mergedCells'.
    > But I get a "400" error from the following VBA code:
    >
    > [mergedCells].ClearContents
    >
    > That seems odd. Is there a workaround?
    >
    > Art


  3. #3
    Tom Ogilvy
    Guest

    Re: Clear Contents won't work on merged cells

    This demo from the immediate window worked for me:

    Range("C1:D1").Merge
    Range("C1").MergeArea.Name = "MergedCells"
    rANGE("c1").Value = "Merged Cells"
    ? range("C1").Value
    Merged Cells
    ? Range("MergedCells").Address
    $C$1:$D$1
    Range("MergedCells").ClearContents

    IF it is a 400 error in a dialog with a circled red X or something like that
    and no message, I believe that is caused by a bug in Excel, not trying to
    clearcontents. Try closing and reopening excel and the workbook.

    Tested in xl2002
    --
    Regards,
    Tom Ogilvy


    "ArthurJ" <[email protected]> wrote in message
    news:[email protected]...
    > I have merged cells C1 and D1, and named it 'mergedCells'.
    > But I get a "400" error from the following VBA code:
    >
    > [mergedCells].ClearContents
    >
    > That seems odd. Is there a workaround?
    >
    > Art




+ 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