View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_4_] Dick Kusleika[_4_] is offline
external usenet poster
 
Posts: 595
Default Don't run if entire column is selected

Elaine

You can test for the number of cells in the selection.

If Selection.Cells.Count < 100 Then
'Do stuff
End If

That might be better than checking if the whole column is selected. But, to
answer your question:

If Selection.Address < Selection.Rows(1).EntireColumn.Address Then
'It's okay to do stuff
End If

In either of these cases, you may want to test Typename(Selection) = "Range"
because if something other than a range is selected, you'll get errors.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Elaine wrote:
I have a small macro which formats selected cells. How I can get an
error message if an entire column is selected? I don't want all 65000
odd cells in that column to be formatted.

I see that Columns("E:E").Select selects all cells in column E but I
don't know in advance which column will be selected as the format
macro will work on any block of cells selected.

Thanks.