+ Reply to Thread
Results 1 to 5 of 5

Referring to merged cells

  1. #1
    Registered User
    Join Date
    07-04-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    44

    Referring to merged cells

    I'm trying to find out how to refer to merged cells.

    e.g. Cells b2, c2, d2, e2 have been merged into one cell.

    I've vb code how can I refer to that merge cell.

    When I palace code it says that you can't use code in merged cells


    Also this code works but is there an easier way to write it?

    Range("G4").ClearContents
    Range("G13").ClearContents
    Range("G22").ClearContents
    Range("G31").ClearContents
    Range("G40").ClearContents
    Range("B12").ClearContents
    Range("B21").ClearContents
    Range("B30").ClearContents
    Range("B39").ClearContents
    Range("B48").ClearContents

    wayneao
    Last edited by wayneao; 07-04-2014 at 08:46 PM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Referring to merged cells

    Hi wayneao and welcome to the forum,

    1. See the code in post #14 of the following thread concerning VBA code and merged cells: http://www.excelforum.com/excel-form...ml#post3756729 In general, you can only access the 'top left' cell of a Merged Cell.

    2. I think your 'ClearContents' code is fine as is, since you are clearing non-contiguous areas.

    Lewis

  3. #3
    Registered User
    Join Date
    07-04-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Referring to merged cells

    One suggestion was to rename merged cell.

    I tried that and it worked fine but i was hoping that there might be an easier was to do it.

    By the way the code for the merged cell is to clearcontents.

    It run through a button on click.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,583

    Re: Referring to merged cells

    It is better to use,
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-04-2014
    Location
    Montreal, Canada
    MS-Off Ver
    Excel 2010
    Posts
    44

    Re: Referring to merged cells

    Thanks for the clarification.
    I'm new with excel and not use the code procedure. So little tips like this are helpful.

    Thanks again
    Wayneao

    One other thing. When I go to my posts it only shows two replies yet the are four in total. How do I see the other two?

+ 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. Replies: 1
    Last Post: 06-28-2012, 11:53 AM
  2. Referring to cells
    By april27 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-16-2006, 10:20 AM
  3. how do i link merged cells to a merged cell in another worksheet.
    By ibbm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-27-2006, 06:45 PM
  4. width of Merged cells within un merged cells
    By Darin Kramer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2005, 06:05 AM
  5. [SOLVED] retrieve text from merged cells-How do i read the text in the merged cell?
    By Eric in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2005, 05:05 AM

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