If only one cell is selected then...

The Tamer

Well-known Member
Joined
Jun 10, 2004
Messages
520
Hi

How do I say in vba code:

If only one cell is selected then do X
otherwise
do Y

Thanks

Tamer
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How about:

Code:
If Selection.Cells.Count Then 
' Do something
Else
' Do something else
End If
 
Upvote 0
Modification on Norie's post.

Code:
If Selection.Cells.Count > 1 Then
' Do something - A range is selected
Else
' Do something else - A cell is selected
End If
 
Upvote 0
Modification on Norie's post.

Thanks

I'm really going to have to double check my posts before submitting them.
 
Upvote 0

Forum statistics

Threads
1,202,914
Messages
6,052,534
Members
444,590
Latest member
GCLee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top