ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection (https://www.excelbanter.com/excel-programming/339496-selection.html)

Bill[_30_]

Selection
 
Hello,
How can I tell if an entire column has been selected or just a few cells in
the column?

Thanks,

Bill



Peter Rooney

Selection
 
Bill,

How about calling this, once your cells are selected?

Sub IsItAColumn()

Dim CountCell As Range
Dim Count As Long

For Each CountCell In Selection
Count = Count + 1
Next
If Count = 65536 Then
MsgBox ("You've selected the entire column")
Else
MsgBox ("You've just selected cells")
End If
End Sub

Mind you, you might need to make it a bit more clever if you selected (for
example)8 columns by 8192 rows, which equates to the same thing i.e. 65536

Hope this helps

Pete

"Bill" wrote:

Hello,
How can I tell if an entire column has been selected or just a few cells in
the column?

Thanks,

Bill




Dave Peterson

Selection
 
Just a single column?

if selection.address = selection.cells(1).entirecolumn.address then
'whole column
else
'not whole column
end if



Bill wrote:

Hello,
How can I tell if an entire column has been selected or just a few cells in
the column?

Thanks,

Bill


--

Dave Peterson

Bill[_30_]

Selection
 
Thanks Dave,
It could be multiple columns as well.

Bill
"Dave Peterson" wrote in message
...
Just a single column?

if selection.address = selection.cells(1).entirecolumn.address then
'whole column
else
'not whole column
end if



Bill wrote:

Hello,
How can I tell if an entire column has been selected or just a few cells
in
the column?

Thanks,

Bill


--

Dave Peterson




Dave Peterson

Selection
 
if selection.address = selection.entirecolumn.address then



Bill wrote:

Thanks Dave,
It could be multiple columns as well.

Bill
"Dave Peterson" wrote in message
...
Just a single column?

if selection.address = selection.cells(1).entirecolumn.address then
'whole column
else
'not whole column
end if



Bill wrote:

Hello,
How can I tell if an entire column has been selected or just a few cells
in
the column?

Thanks,

Bill


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 06:42 PM.

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