View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default distinguish Range and "Single"

Probably better to use Z.Cells.Count, rather than rely on the default.
Especially since there's no visible cue that Z may refer to a range.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Tom Hutchins" wrote in message
...
You can just use Z.Count to count the cells in range Z.

Hope this helps,

Hutch

"Dietmar M. Kehrmann" wrote:


Hi,

I have to do different things ([BLOCK 1] and [BLOCK 2]) if Z is a
"Single" (a number or a Range of 1x1) or if Z is a Range (a genuine, not
1x1). My workaround is like

If TypeOf Z Is Range Then
If (Z.Rows.Count=1) And (Z.Columns.Count=1) Then
[Block 1]
Else
[Block 2]
End If
Else
[Block 1]
End If


but I don't like it: [Block 1] two times and the construction
'(Z.Rows.Count=1) And (Z.Columns.Count=1)' seems to be ugly.

I guess that this problem appears frequently.
What would be a good solution?