Getting Cell Reference With Input Box

Posted on the September 9th, 2008 under Excel VBA Function by Poer @ Excel VBA/Macro

We can get an input from user using Input Box, but we also can use the Input Box to get the address of cell reference in Microsoft Excel.

Using simple Excel VBA procedure below we can ask user to select range of cells (as copy input) and where they want it paste.

Sub CopyPaste()

Dim InputCells As Excel.Range
Dim OutputCells As Excel.Range

On Error Resume Next

'Show input box to get range of cells that want to copy
Set InputCells = _
Application.InputBox(Prompt:="Block input cells/range", _
Title:="Copy Paste", Type:=8)

'Show input box to get where they want it paste
Set OutputCells = _
Application.InputBox(Prompt:="Select cell where you want paste it", _
Title:="Copy Paste", Type:=8)

'Copy range of input cells
InputCells.Copy

'Paste it into output cells reference
OutputCells.PasteSpecial (xlPasteAll)

End Sub

Run the excel macro, when the first input box show up, block range of cells that we want to copy, click OK, and when the second input box showed, choose destination cell and click OK, then the source cells will be copied into the destination cell.

Related Entries

External Resources

Tagged with:

6 Responses to 'Getting Cell Reference With Input Box'

  1. October 18, 2008 at 4:35 am
    JP
  2. October 25, 2008 at 1:40 pm
    admin
  3. November 7, 2008 at 9:59 am
    James Quinn
  4. June 10, 2009 at 2:47 am
    pankaj
  5. June 14, 2009 at 11:17 pm
    Excel VBA Macro
  6. June 21, 2009 at 3:23 pm
    Viviana Maphis

Leave a Reply




XHTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
SYNTAX HIGHLIGHTER:
Place your VBA code between <pre> tags like this <pre class="brush:vb"> sub vba() ... end sub </pre>.