What has the User selected?

  • Thread starter Thread starter Bony Pony
  • Start date Start date
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
 
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
 
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
 
Hi Joel / Jacob,

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

Kind regards,
Bony
 
Back
Top