mcomp72
Active Member
- Joined
- Aug 14, 2016
- Messages
- 275
- Office Version
- 365
- 2019
- 2016
- 2011
- Platform
- Windows
- MacOS
I am trying to count the number of cells in the range that the user has currently selected. Generally, I know how to do this with the following code:
However, if there are any merged cells in the selected area, I need it to count the merged cell as only one cell. Unfortunately, the above code doesn't do that. I've tried coming up with other ways to do it, but nothing has worked. I'm stumped as to how to accomplish this. Anyone have any ideas?
VBA Code:
Dim TheCount As Integer
TheCount = Selection.Rows.count * Selection.Columns.count
However, if there are any merged cells in the selected area, I need it to count the merged cell as only one cell. Unfortunately, the above code doesn't do that. I've tried coming up with other ways to do it, but nothing has worked. I'm stumped as to how to accomplish this. Anyone have any ideas?