ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   From Cell to InputBox (https://www.excelbanter.com/excel-programming/284983-cell-inputbox.html)

Robin Clay[_3_]

From Cell to InputBox
 
Greetings !

My code, after a "button" is pressed, throws an InputBox
onto the screen.

I want in reply to insert a value already displayed in a
Cell.

This I can do by selecting the cell before hand, pressing
F9 and then Ctrl C followed by Esc. Then I click on
the "button", and press Ctrl V at the InputBox.

That's fine for one value, but the InputBox is followed by
another, into which I want to paste the value from another
cell.

Yes, I COULD type it in - but that's not a satisfactory
solution !

I guess one way would be to type in the Cell Reference -
but is there a way that I could click on the required
Cell ?

There are ocasions when (say) "G72" would be a valid
answer, when I actually want the VALUE in that Cell (which
might be "J136", say)


RClay AT haswell DOT com

Tom Ogilvy

From Cell to InputBox
 
Dim rng as Range
On Error Resume Next
set rng = Application.InputBox("Select cell with mouse", Type:=8)
On Error goto 0
if not rng is nothing then
vVal = rng(1).value
else
msgbox "you hit cancel"
End if

This will get a reference to the selected cell or you can type in an
address. You can't type in the value, however.

Once you have the cell reference, your code can use the value of that cell.

--
Regards,
Tom Ogilvy


"Robin Clay" wrote in message
...
Greetings !

My code, after a "button" is pressed, throws an InputBox
onto the screen.

I want in reply to insert a value already displayed in a
Cell.

This I can do by selecting the cell before hand, pressing
F9 and then Ctrl C followed by Esc. Then I click on
the "button", and press Ctrl V at the InputBox.

That's fine for one value, but the InputBox is followed by
another, into which I want to paste the value from another
cell.

Yes, I COULD type it in - but that's not a satisfactory
solution !

I guess one way would be to type in the Cell Reference -
but is there a way that I could click on the required
Cell ?

There are ocasions when (say) "G72" would be a valid
answer, when I actually want the VALUE in that Cell (which
might be "J136", say)


RClay AT haswell DOT com





All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com