Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default If Selection is one cell

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 434
Default If Selection is one cell

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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default If Selection is one cell

Thanks. But when I select the whole sheet, I get the error, overflow. How can
I Correct this?



"Héctor Miguel" wrote:

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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 434
Default If Selection is one cell

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 __
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If Selection is one cell


You must be usng Excel 2007, there are too many cells for count to
handle.
Why select all cells I doubt if all the cells in 2007 will ever be
used, use UsedRange or CurrentRegion insteadnstead


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99941



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default If Selection is one cell


Something like this

Code:
--------------------

If Selection.Count 1 Then MsgBox Selection.Count

--------------------


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=99941

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default If Selection is one cell

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
---------------
Jacob Skaria


"art" wrote:

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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default If Selection is one cell

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
---------------
Jacob Skaria


"art" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
Copy Selection - Paste Selection - Delete Selection Uninvisible Excel Programming 2 October 25th 07 01:31 PM
How to create a selection list then display the selection in a cell [email protected] Excel Programming 0 August 1st 07 03:01 PM
Change from Column Selection to Cell Selection Lil Pun[_16_] Excel Programming 4 June 16th 06 10:38 PM
limit cell list selection based on the selection of another list lorraine Excel Worksheet Functions 2 December 14th 04 08:17 PM


All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"