MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Selecting entire row or column


Posted by Simon Pennie on January 23, 2002 2:49 AM

Is there a way with VBA to determine if a user has selected an entire row or column rather than just individual cells?


Posted by Bariloche on January 23, 2002 4:32 AM

Simon,

Here's a way:


Sub DetermineSelection()

With Selection
If .Rows.Count = 65536 Then MsgBox "You selected an entire column"
If .Columns.Count = 256 Then MsgBox "You selected an entire row"
If .Rows.Count = 1 And .Columns.Count = 1 Then MsgBox "You've selected only one cell"
End With

End Sub


enjoy

Posted by Simon Pennie on January 23, 2002 8:19 AM

Thanks
That is one way to do it. I was wondering if there is a property in the object model that can be read to find out if an entire row or column is selected?