Counting number of cells in a row and columns taken by a merged cell

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
582
Office Version
  1. 365
Is there a way of returning a count of the number of cells in a merged area?

For example if I merged from A1 : D2 I would want it to return 4 x 2 as it expands over 4 columns, and over 2 rows. (Ideally I then need each answer multiplied by 5 so, it would then return 20 x 10

(All cells in the merged area are blank)

Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
This will show you how to count rows, columns, and cells in a merged range:
VBA Code:
Sub MyCode()

    Dim numCells As Long
    Dim numRows As Long
    Dim numCols As Long
    
    numCells = Range("A1").MergeArea.Cells.Count
    MsgBox "The total number of cells in the merge area is: " & numCells
    
    numRows = Range("A1").MergeArea.Rows.Count
    numCols = Range("A1").MergeArea.Columns.Count
    
    MsgBox numCols * 5 & " x " & numRows * 5
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,086
Messages
6,123,033
Members
449,092
Latest member
ikke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top