Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like the final appearance after my VBA has finished running to be empty of selection -- to have no cell or range on any sheet colored (if it was range selected) or in a bold line box (anything that was selected). Pupose: to present the client with a neat final appearance.

I've searched and cannot find how to do this. There is an Unselect according to MS, but it doesn't seem to do anything.

share|improve this question
Why don't you select cell A1 when you save to present a clean look. If you want to strip cell formatting that is a different thing. – wbeard52 Sep 4 '12 at 0:09
The cursor has to be somewhere. Why not place it bottom right with Worksheets("xxxx").Cells(Rows.Count,Columns.Count).Select or anywhere that is at least a screen away from the used area. – Tony Dallimore Sep 4 '12 at 8:16
could you just place it back where it was when the macro was called? – SeanC Sep 4 '12 at 15:45

Select any cell and turn off CutCopy:

  Application.CutCopyMode = False
share|improve this answer

The only answer is to cheat.

Hide column A and row 1

Put cursor in A1. There will be a tiny dot in the corner of B2

share|improve this answer
or you could select a cell outside of the viewable range. – KronoS Sep 5 '12 at 18:21
@KronoS, which at 10% zoom, and a 1280x1024 screen is ~HA375. perhaps XFD1048576 ? :) – SeanC Sep 5 '12 at 18:25

Excel always has something selected. A work around is needed. Selecting a cell off screen will set focus there, so that won't work in and of itself. This code places the cursor off screen and then scrolls the sheet back up to view A1.

Sub NoSelect()    
  ActiveWindow.SmallScroll up:=100
  ActiveWindow.SmallScroll ToLeft:=44
End Sub

If you are really wanting 'nothing selected`, you can use VBA to protect the sheet at the end of your code execution, which will cause nothing to be selected. You can either add this to a macro or put it into your VBA directly.

Sub NoSelect()
   With ActiveSheet
   .EnableSelection = xlNoSelection
   End With
End Sub

As soon as the sheet is unprotected, the cursor will activate a cell.

share|improve this answer

There is a tricky way to do it.

Create an object such as a button. Select this button, then hide it, and no cell will be selected.

ActiveSheet.Shapes("Button 1").Visible = True

ActiveSheet.Shapes("Button 1").Select

ActiveSheet.Shapes("Button 1").Visible = False

That's it.

share|improve this answer

Depending on the size of your selection, to get rid of any artifacting (I don't know if this is also an issue in 2013 Excel, but on Mac it was a constant pain for me) you can just loop through cell by cell and select each.

share|improve this answer

By turning off screen updating before selecting a cell, scroll to selected cells is temporarily disabled.

This code checks which cells are currently visible and selects the first cell below the visible range which is not in view. Eg, when i try it: Visble range is A1:BC79, so this code selects A80 and scrolling down and to the right and running it again reveals the excel chooses the first cell NOT visible below the first visible column.

Dim r As Range
Application.ScreenUpdating = False
Set r = Application.ActiveWindow.VisibleRange
r(r.Cells.Count + 1).Select
Application.ScreenUpdating = True

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .