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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top