Skip to content

Instantly share code, notes, and snippets.

@strickc
Created March 6, 2017 01:13
Show Gist options
  • Save strickc/e0840888b52fac6b837ea96a4a269759 to your computer and use it in GitHub Desktop.
Save strickc/e0840888b52fac6b837ea96a4a269759 to your computer and use it in GitHub Desktop.
VBA excel prompt user to select range
' Mutates the range passed in the paramter to a user selected value.
' Returns true if range is set, or false if not set (i.e. the user pressed cancel)
Function promptForRange(prompt As String, title As String, ByRef res As Range) As Boolean
promptForRange = False
On Error Resume Next
Set res = Application.InputBox(prompt, title, , , , , , 8)
On Error GoTo 0
If Not res Is Nothing Then promptForRange = True
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment