Skip to content

Instantly share code, notes, and snippets.

@ndthanh
Created July 22, 2017 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndthanh/3768a542ef774bcd5faf919be2614155 to your computer and use it in GitHub Desktop.
Save ndthanh/3768a542ef774bcd5faf919be2614155 to your computer and use it in GitHub Desktop.
Sub UnSelectCell()
'Updateby20140314
Dim rng As Range
Dim InputRng As Range
Dim DeleteRng As Range
Dim OutRng As Range
xTitleId = "Hoc Excel Online"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set DeleteRng = Application.InputBox("Delete Range", xTitleId, Type:=8)
For Each rng In InputRng
If Application.Intersect(rng, DeleteRng) Is Nothing Then
If OutRng Is Nothing Then
Set OutRng = rng
Else
Set OutRng = Application.Union(OutRng, rng)
End If
End If
Next
OutRng.Select
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment