+ Reply to Thread
Results 1 to 10 of 10

Count Cells in a merged Cell

Hybrid View

23-zeros Count Cells in a merged Cell 08-03-2015, 11:37 PM
mangesh.mehendale Re: Count Cells in a merged... 08-04-2015, 12:03 AM
23-zeros Re: Count Cells in a merged... 08-04-2015, 01:34 AM
cyiangou Re: Count Cells in a merged... 08-04-2015, 12:42 AM
23-zeros Re: Count Cells in a merged... 08-04-2015, 01:37 AM
protonLeah Re: Count Cells in a merged... 08-04-2015, 12:47 AM
23-zeros Re: Count Cells in a merged... 08-04-2015, 01:41 AM
cyiangou Re: Count Cells in a merged... 08-04-2015, 12:56 AM
FDibbins Re: Count Cells in a merged... 08-04-2015, 01:34 AM
cyiangou Re: Count Cells in a merged... 08-04-2015, 01:41 AM
  1. #1
    Registered User
    Join Date
    08-03-2015
    Location
    iran
    MS-Off Ver
    2013
    Posts
    4

    Question Count Cells in a merged Cell

    hello people, I'd like to count Cells that have values in a merged format, is this even possible? tnx indeed.

    Book1.xlsx

  2. #2
    Valued Forum Contributor mangesh.mehendale's Avatar
    Join Date
    06-04-2015
    Location
    India
    MS-Off Ver
    2007
    Posts
    510

    Re: Count Cells in a merged Cell

    Welcome to forum... please explain how these are 19 and 14
    Don`t care, take care...

    Regards,
    Mangesh

  3. #3
    Registered User
    Join Date
    08-03-2015
    Location
    iran
    MS-Off Ver
    2013
    Posts
    4

    Re: Count Cells in a merged Cell

    @mangesh.mehendale Thank you so much, sorry to post this thread before I introduced myself, will do asap.
    imagine there were no merged cells in this sheet, and we wanted to count the duplicated values and also non duplicated in merged cells, that's what I'm after.

  4. #4
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Count Cells in a merged Cell

    Vba Function:

    Public Function MergeCellCount(Rng As Excel.Range) As Long
        Dim Cell As Excel.Range
        Dim Count As Long
        Count = 0
        For Each Cell In Rng
            If Not IsEmpty(Cell.MergeArea.Cells(1, 1).Value) Then
                Count = Count + 1
            End If
        Next
        MergeCellCount = Count
    End Function
    merge_cell_count_cy.xlsm

  5. #5
    Registered User
    Join Date
    08-03-2015
    Location
    iran
    MS-Off Ver
    2013
    Posts
    4

    Re: Count Cells in a merged Cell

    Quote Originally Posted by cyiangou View Post
    Vba Function:

    Public Function MergeCellCount(Rng As Excel.Range) As Long
        Dim Cell As Excel.Range
        Dim Count As Long
        Count = 0
        For Each Cell In Rng
            If Not IsEmpty(Cell.MergeArea.Cells(1, 1).Value) Then
                Count = Count + 1
            End If
        Next
        MergeCellCount = Count
    End Function
    Attachment 411577
    Wow, thank you man, That's exactly What I meant, how should I return the favor?
    Last edited by 23-zeros; 08-04-2015 at 01:44 AM.

  6. #6
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,937

    Re: Count Cells in a merged Cell

    When cells are merged, only the upper left cell holds the value. COUNT is not counting cells, it is counting the number of cells with numbers; therefore, 10 not 19. You merged A5:A7 and entered 78 in the merged area, but only cell A5 is holding the 78 so count is one not three.
    Ben Van Johnson

  7. #7
    Registered User
    Join Date
    08-03-2015
    Location
    iran
    MS-Off Ver
    2013
    Posts
    4

    Re: Count Cells in a merged Cell

    Quote Originally Posted by protonLeah View Post
    When cells are merged, only the upper left cell holds the value. COUNT is not counting cells, it is counting the number of cells with numbers; therefore, 10 not 19. You merged A5:A7 and entered 78 in the merged area, but only cell A5 is holding the 78 so count is one not three.
    I know merging is not recommended at all, but I needed this for a lot of sheets that the end user works with and knows nothing about excel at all, I tried to unmerge the cells and entered the same value in them, but it's hard to work due to the users eyes, but I think I could use the cyiangou's VBA function to solve this. tnx anyways
    Last edited by 23-zeros; 08-04-2015 at 01:43 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Count Cells in a merged Cell

    This also had me arguing for awhile, but 23-zeroes spec is exactly consistent with his expected result.

    count Cells that have values in a merged format
    or 'count cells whose containing mergeareas have values entered'
    Last edited by cyiangou; 08-04-2015 at 01:06 AM.

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Count Cells in a merged Cell

    Based on the sample answers (19 and 14), this cannot be done with regular formulas. As Ben said a merged cell (of however many cells) becomes 1, so excel will count that sample as 10 and 5
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Count Cells in a merged Cell

    A pleasure. An 'Add Reputation' to the left of my post would be good. Thanks!

    (also mark as SOLVED in the thread tools at the top of the page)

+ 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. Formulas don't count merged cells
    By PinkMafia14 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-15-2015, 04:58 AM
  2. Unable to =Count() Cells that were once Merged
    By JoshDR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2015, 03:34 PM
  3. [SOLVED] Formula or VBA or Combination to count Number of Cells in a merged range! PLEASE HELP!
    By WaylettChris in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-13-2014, 11:02 AM
  4. UDF to count colored cells AND merged cells
    By blackhawk98ss in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-01-2014, 04:09 PM
  5. count rows within specific merged cells
    By Kram222 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-15-2012, 07:38 AM
  6. [SOLVED] 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
  7. Errors in COUNT, COUNTA, COUNTIF when counting merged cells
    By Outback in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-07-2006, 12:35 PM

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