I want my worksheet to have ZERO cells selected

phantom1975

MrExcel MVP
Joined
Jun 3, 2002
Messages
3,962
What I am trying to do is set up a Selection_Change event that will make the selection thingy disappear. The only thing I can think of is something like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

Application.EnableEvents = False
Me.Range("A10").Activate
'Rows 10 and below are hidden
ActiveWindow.LargeScroll Up:=1
Application.EnableEvents = True

End Sub


I'm sure there is a better way to do this. Any suggestions?
 
Justinlabenne said:
Out of curiosity, if you need to select cells, but have no "cell selector" how would you tell what cell you on. Im interested in what your after here, for what purpose, seems crazy, but interesting... :biggrin:

Let's say the user clicks cell A1 to run the macro for that cell. What if the user wants to run the macro again? The user would have to click out of cell A1 and then click it again. Too cumbersome. The other reason for this is for aesthetics. I could have the macro simply select another cell after the macro has run (in my example, cell A10) so that the user can easily click A1 again. But then there is the matter of that ugly highlighted cell there.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If that's the effect you want to achieve, then you can try this, following these steps in order:

(1)
Comment out any existing Selection event code in your worksheet module.

(2)
Draw a small ActiveX Label control on a cell whose column or row you can hide, for this example put the label within the confines of cell J2. Note, "small" means small, and "within" means within. Make the label tiny in size so it easily does not touch any of the cell's borders.

(3)
Go into design mode, right click on the Label control, left click on Format Control, and on the Properties tab select "Move and size with cells". Also, deselect "Print object".

(4)
Click onto any cell to deselect the Label. Exit design mode. Hide column J.

(5)
Amend and uncomment your existing Sheet selection code per the following syntax:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

MsgBox "Your code"

Application.EnableEvents = False
Range("J1").Select
Application.EnableEvents = True
ActiveSheet.Label1.Select
End Sub

(6)
You will notice the formula bar will contain the script
=EMBED("Forms.Label.1","")
while the label is selected. You can ameliorate that by either
- hiding the formula bar
- protecting the sheet, making sure to adjust the codde accordingly
- ignoring the formula bar
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,391
Members
449,445
Latest member
JJFabEngineering

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