Home » Questions » Computers [ Ask a new question ]

Excel VBA: how to clear a selection without activating the sheet

Excel VBA: how to clear a selection without activating the sheet

Edit:

Asked by: Guest | Views: 171
Total answers/comments: 1
Guest [Entry]

"erm, you can always use VBA to reference the worksheet and cell range?

Option Explicit

Sub RemoveValues()
Worksheets(""ACME_Sales"").Range(""A1:B17"").ClearContents
End Sub

This will clear off cells A1 to B17 in the worksheet ACME_Sales.

EDITED Edit answer to reflect edited question.

Sub SelectNewCell()
Worksheets(""ACME_Sales"").Select
Range(""E2:E2"").Select
End Sub

This will let VBA remove any selection on ACME_Sales and then just select the cell E2."