+ Reply to Thread
Results 1 to 7 of 7

VBA PasteSpecial Named Range - Cannot change part of a merged cell

  1. #1
    Registered User
    Join Date
    07-18-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    88

    Question VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Hi,

    I'm trying to paste special a named range in Excel 2007 but I get run-time error 1004: "Cannot change part of a merged cell".

    Please Login or Register  to view this content.
    An example of one of the parts of the named range would be cells E16&E17 merged but cell E16 contains the data so that is referenced in the named range.


    Any help would be appreciated.

    Thanks,
    M

  2. #2
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Can you explain again as I have Set up a named range from E16:E30 and merged E16:E17 and the below code runs without error.

    Please Login or Register  to view this content.
    as does

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  3. #3
    Registered User
    Join Date
    07-18-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Thanks for the quick response! I am however having difficulty in running them, a lot of them fail on the .Copy function.

    I've tested them all:

    1. Pastes the same value to all cells, doesn't randomise
    2. Error 1004 - Bugs on the .Copy function
    3. As above
    4. As above
    5. Doesn't paste special the values, the formulas still exist

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Not for me, I am afraid I don't get any of those. Please see the attached.

    If your merged cells range covered cells that were partly outside the named range say in the attached instead I merged E16:F17 then you will get the run-time error 1004: "Cannot change part of a merged cell" message.

    That is because only part of the range in in the merged cells (as the error states).

    So in your case if E16 is the named range and E17 is outside the named range then you will get the error.
    Then all you can really do is unmerge the cells then remerge them or as it is regularly stated "Avoid using merged cells when coding" (or ever ).
    Attached Files Attached Files
    Last edited by WasWodge; 06-22-2016 at 06:59 AM.

  5. #5
    Registered User
    Join Date
    07-18-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Okay so I've fixed the merged cell issue.

    I'm now getting an error "That command cannot be used on multiple sections"

    My named range covers several cells across the worksheet that aren't directly near each other.

    Is there an alternative to the .Copy scenario?

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Something like...

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-18-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: VBA PasteSpecial Named Range - Cannot change part of a merged cell

    Got it working in the end, thanks!

+ 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. Use VBA to stop 'cannot change part of merged cell' alert..
    By igullage in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-08-2015, 01:21 PM
  2. [SOLVED] determining if cell is part of named range and what that named range is
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2014, 07:56 PM
  3. cannot change part of a merged cell
    By darren w in forum Excel General
    Replies: 3
    Last Post: 02-28-2013, 12:54 PM
  4. Error: Cannot change the part of merged cell - When trying to lock cells in range
    By Ranjani in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-09-2009, 12:03 PM
  5. Cannot change part of a merged cell
    By happyPotter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2005, 01:05 PM
  6. ClearContent & 'Cannot change part of a merged cell' error
    By Richard in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-27-2005, 04:05 PM
  7. [SOLVED] Is the active cell part of a named range
    By Virginia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-23-2005, 02:07 PM

Tags for this Thread

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