ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Input box display (https://www.excelbanter.com/excel-programming/444186-input-box-display.html)

Slim Slender[_3_]

Input box display
 
I'm using an input box to gather a condition for a macro. I found out
that I could click in a cell containing the needed data as well as
typing in the input box. When I click on a cell the input box displays
the cell reference rather than the cell content. Is there a way to
have the input box display the content, for example 1/27/2011, rather
than the reference =$E$238, for example?

GS[_2_]

Input box display
 
Slim Slender presented the following explanation :
I'm using an input box to gather a condition for a macro. I found out
that I could click in a cell containing the needed data as well as
typing in the input box. When I click on a cell the input box displays
the cell reference rather than the cell content. Is there a way to
have the input box display the content, for example 1/27/2011, rather
than the reference =$E$238, for example?


This suggests you're using Excel's InputBox method rather than VBA's
InputBox function. In this case, selecting cells is possible because
the control is actually a refedit and so will return the selection
address. That said, to get the cell contents you can use the address in
the normal fashion:

sMyVal = Application.InputBox... '//get cell reference
sMyVal = Range(sMyVal).Value '//replace with contents

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



GS[_2_]

Input box display
 
I should have said the var sMyVal should be declared as Variant type.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 06:30 AM.

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