What has the User selected?

B

Bony Pony

Hello ever helpful people,
If a user selects a range in a sheet, is it possible to determine if he has
selected a range of cells or an entire row or column?

I have tried naieve things like
for each mycell in selection
if mycell.selection.entrierow = true then ...

but no luck.
Any help please?

many thanks,
Bony
 
J

Jacob Skaria

If Selection.cells.count = columns.count And selection.rows.count=1 Then
'1 full Row selected

If selection.rows.count = rows.count And selection.columns.count=1 then
'1 full Column selected

In 2007 you need to use .CountLarge

If this post helps click Yes
 
J

Joel

The code is correct. When myrange.Rows.Count = Rows.Count indicates the
entire column is selected. Same applies for entire row.


Set myrange = Selection
MsgBox (myrange.Address)
MsgBox (myrange.Rows.Count)
MsgBox (myrange.Columns.Count)

If myrange.Rows.Count = Rows.Count Then
MsgBox ("entire column is selected")
End If

If myrange.Columns.Count = Columns.Count Then
MsgBox ("entire row is selected")
End If
 
B

Bony Pony

Hi Joel / Jacob,

Many thanks! As always, the answer within Excel is to think laterally and
keep it simple,

Kind regards,
Bony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top