ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Select case bugging out (https://www.excelbanter.com/excel-discussion-misc-queries/240777-select-case-bugging-out.html)

jlclyde

Select case bugging out
 
Any idea on why I keep getting Application-defined or object-defined
error when it gets to this line of code?

Select Case Selection.MergeArea.Cells.Count

Thanks in advance for the help.
Jay

Jim Thomlinson

Select case bugging out
 
Depends on what your selection is. The merge area property only works if the
range (in this case Selection) is a single cell. For example try this...
Create a Merger area of cells A1:B2
Now run this code...

MsgBox Range("A1").MergeArea.Cells.Count

and you will get 4.

This code will not work

MsgBox Range("A1:B1").MergeArea.Cells.Count

as the merge area for A1 and B1 may or may not be the same (it is in this
case but it does not have to be)...

Now to the big question... What exactly are you trying to do???
--
HTH...

Jim Thomlinson


"jlclyde" wrote:

Any idea on why I keep getting Application-defined or object-defined
error when it gets to this line of code?

Select Case Selection.MergeArea.Cells.Count

Thanks in advance for the help.
Jay



All times are GMT +1. The time now is 04:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com