Daily tips for using Microsoft Excel.

Tuesday, January 29, 2002

Today, another VBA tip. Sometimes, the InputBox function just isn't enough... you need to let the user point to a cell, instead of having to write in what you want. This cannot be done using this Inputbox, but, can be done using Excel's Inputbox, as follows:

Application.Inputbox(Prompt:="Choose a cell",Title:="Choose",Type:=8)

This returns False if canceled, or a reference to the cell/range selected. That way, you could set it to a variable, like

Set MyRange = Application.Inputbox(.....)

You can see the Online help for more Types of this Inputbox.