top of page

InputBox vs Application.InputBox and testing for cancel button


Excel has both an InputBox and Application.InputBox – it’s easy to tell which is nicer on the eye! There are advantages to both, the InputBox is a little easier to work around a cancellation from the user however the Application.InputBox can be used for different Types of data (more details on types click here) the focus here being able to dynamically select a range.

So what’s the purpose of this? Excel VBA users have been searching for a way to be able to click that little “Cancel” button or “X” without having a False value or causing an error and stopping your code.

The below code goes into detailed step by step on how you can select and confirm a range and then add text to that range and being able to cancel both Application.InputBox dialog boxes.

In the code you can choose two methods, Method 1 has the Application.InputBox dialog box pop up to confirm/change the selected range where Method 2 continues with the already selected cells prior to running the code.

Example Code of this in effect, this code adds text to a Selected Range of cells

Download example file: InputBox Text to Range example.txt

Search By Tags
No tags yet.
Featured Posts
Recent Posts
Follow Me
  • Facebook Classic
  • Twitter Classic
  • Google Classic
bottom of page