Inputbox used to return value of selected cell

B

Bob Phillips

Donald,

Using Application.Inputbox you can select a cell.

This code sets a cell to that value
myCell = Application.InputBox(prompt:="Select a cell", Type:=8)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
H

Harald Staff

Hi Donald

Not too sure I understand what you're after. But here's an inputbox that
prompts you to click a cell and returns the clicked cell and its address.
Who knows, maybe you need exactly that one day ?

Sub ClickACell()
Dim R As Range
On Error Resume Next
Set R = Application.InputBox("Click a cell:", _
Default:=ActiveCell.Address, _
Type:=8)
If R Is Nothing Then
MsgBox "cluck cluck"
Else
Set R = R(1)
MsgBox R.Address, , "A fine choice!"
End If
End Sub
 
B

Bob Phillips

Donald,

Just tag .Address to the end.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top