MsgBox question

rjc4

Well-known Member
Joined
Nov 6, 2004
Messages
502
Hello all,

Below is my code to allow the user to enter their name. Works fine!

However, can I modify the code to display the contents of a cell in the body of the box.

The box just shows “START FROM HERE”.
I would like to add to this the contents of cell R6 which is a number, so it would show
“START FROM HERE. The last number is 853". (cellR6 contains 853).
Can this be done.

It does not matter whether it shows in the header My INPUT Box or the body or the entry line as long as I can show it somewhere. I can get around it by using a message box but I then have two boxes displaying.

Thankyou
RC

Code:
Dim rng_Original As Excel.Range
Dim vnt_GetInput As Variant

Set rng_Original = ActiveCell
Application.Goto reference:="R3C17"

vnt_GetInput = Application _
.InputBox("START FROM HERE", _
"My INPUT Box", "Enter your name")

If vnt_GetInput <> False Then
ActiveSheet.Range("Q3").Value = vnt_GetInput
End If

rng_Original.Select
Set rng_Original = Nothing
 

Some videos you may like

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

shippey121

Well-known Member
Joined
Mar 21, 2006
Messages
1,001
i would first get the value from the cell R6 and put it into a variable like

x = [r6].value

then i would add this into the input box like this

.InputBox("START FROM HERE " & x, "My INPUT Box", "Enter your name")

try that,

HTH
 

rjc4

Well-known Member
Joined
Nov 6, 2004
Messages
502
Hi Shippey,

That's got it. Thanks for the help.

Just an interesting thing though. If I use your suggestion as below, I get a compile error "Expected =" and the cursor is sitting at the end of the line.
However, if I just amend my code with your suggestions it runs fine.
Perhaps something to do with code being on one line or two. Mystery to me. Come back if you can enlighten.

Cheers for now,
RC :biggrin:

i would first get the value from the cell R6 and put it into a variable like

x = [r6].value

then i would add this into the input box like this

.InputBox("START FROM HERE " & x, "My INPUT Box", "Enter your name")

try that,

HTH
 

shippey121

Well-known Member
Joined
Mar 21, 2006
Messages
1,001
not really sure why it wouldnt work on one line but the code i gave you wasnt the full code only part the full code would be

Code:
vnt_GetInput = InputBox("START FROM HERE " & x, "My INPUT Box", "Enter your name")

or atleast thats how i would have put it

anyway glad you got it to work
 

Watch MrExcel Video

Forum statistics

Threads
1,114,676
Messages
5,549,371
Members
410,911
Latest member
AniEx
Top