If Selection is one cell

  • Thread starter Thread starter art
  • Start date Start date
A

art

Hello:

Hoe do I write the code, if the selection is anything but one cell, So if I
select a range all thew whole page, or a tab or a button etc. it should
ignore everything, only when I select one cell then it should do ....

Thanks

Art
 
hi,Art !
Hoe do I write the code, if the selection is anything but one cell
So if I select a range all thew whole page, or a tab or a button etc.
it should ignore everything, only when I select one cell then it should do ...

i.e.

Sub mySub()
If TypeName(Selection) <> "Range" Then Exit Sub
If Selection.Count > 1 Then Exit Sub
MsgBox "What's next ?", , ""
End Sub

hth,
hector.
 
Thanks. But when I select the whole sheet, I get the error, overflow. How can
I Correct this?
 
hi, Art !
... when I select the whole sheet, I get the error, overflow.
How can I Correct this?

for xl2007 change this:

If Selection.Count > 1 Then Exit Sub

to this:

If Selection.CountLarge > 1 Then Exit Sub

regards,
hector.

__ previous __
 
Sub Macro()
If Selection.Columns.Count <> 1 Or _
Selection.Rows.Count <> 1 Then Exit Sub
'your code starts here


'/your code end here
End Sub


If this post helps click Yes
 
Sub Macro()
If Selection.Rows.Count <> 1 Or _
Selection.Columns.Count <> 1 Then Exit Sub
'your code starts here


'/end
End Sub

If this post helps click Yes
 
Back
Top