Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA: OPIN: Display a value, enter a value for a diff variable

Status
Not open for further replies.

artsandcraftshome

Technical User
Mar 24, 2003
13
US
I need some help on an Operator Interface in Excel. I want to say to the operator, "The value for Variable A is XX; Please enter the value for Variable B".
Variable A is retrieved from a cell reference, and Variable B will be then stored in another cell reference to be used in a calculation. I have tried this in a form using text boxes and a MsgBox but can't get anywhere. I tried selecting the appropriate cell (variable A)and asking VBA to display ActiveCell.Value in the first text box to no avail.
thanks
John
 
Hi John,

I'm not sure I understand the question properly but it seems you could do simply the following:

Code:
Sub GetNewVariableValue

Dim str as string

str = InputBox("The Value of A is " & thisworkbook.sheets("NameofSheet").Range("NameORAddressOfA").Value & ". Please enter value of B.")

thisworkbook.sheets("NameofSheet").Range("NameORAddressOfB").Value  = CDbl(str)

End Sub
[\code]

Hope this helps

Nath
 
Nath-
Thanks alot for responding. I'm having syntax problems I think.
The name for my string is SCDMAX
The name of the workbook is electrons opinnew
The name of the sheet is eCALC
The location of the value of A is E9, and the location where I want to put B is F9
So I wrote SCDMAX = InputBox("The value of A is &electrons Opinnew.eCALC.E9.Value&. Please enter Value B")
electrons opinnew.ecalc.f9.Value = CDbl(SCDMAX)
For one thing, it's not putting up the input box. Then I get a compile error, highlighting the word "Electrons" saying Sub or Function not defined.
Hope this makes sense.
thanks again-
John
 
You should write:

Code:
Dim ws as worksheet
Dim SCDMAX as string

Set ws = Workbooks("electrons Opinnew").Sheets("eCALC")

SCDMAX = InputBox("The value of A is " & ws.Range("E9").Value & ".  Please enter Value B")
ws.Range("F9").Value = CDbl(SCDMAX)

[\CODE]

Nath
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top