Msgbox text to contain string value

mummbles74

Board Regular
Joined
Nov 14, 2009
Messages
120
Office Version
  1. 365
Platform
  1. Windows
I am trying to create a message box that contains text and dim(ed) values in the text as below

Dim Holder As String
Holder = InputBox("Enter Holder")
Dim Updatedate As String
Updatedate = InputBox("Enter Date of day before last update")

I now want to us these values as the msgbox text like

msgbox("your holder is"&holder&"and your date is"&Updatedate&"thankyou")

but this seems not to work. Any idea what I am doing wrong
(this is not the actual text but will give me the info i need)

Thanks in advance for the help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
What are you inputting, and what is your expected output?
 
Upvote 0
It's just nitpicky, it wants spaces between the variables and the & symbols

Try

MsgBox ("your holder is" & Holder & "and your date is" & Updatedate & "thankyou")
 
Upvote 0
Code:
Sub c()
Dim Holder As String
Holder = InputBox("Enter Holder")
Dim Updatedate As String
Updatedate = InputBox("Enter Date of day before last update")
MsgBox ("your holder is " & Holder & " and your date is " & Updatedate & " thank you")
End Sub
 
Upvote 0
thanks just assumed (wrongly) that it would autocorrect the spacing issue.

Thanks again
 
Upvote 0
I think it must fail to auto space the concatenation operator because it is also a type declaration character.

So this is valid VBA:

Code:
Sub Foo()
    MsgBox 100&
End Sub

But I don't recommend the use of type declaration characters as it can be a little confusing to those who don't use them and makes code less readable for such users. It's also inconsistent as some types don't have them (for instance, Byte or Object).
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

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