Using MSG BOX to enter data

Gregfox

Board Regular
Joined
Apr 12, 2011
Messages
120
Hello, I would appreciate help on a problem with MSG BOX.
I would like to have a MSG BOX open and ask questions, and as a result to answering the questions, have the answered put in 4 different cells.
I.e.: MSG BOX-What date?... date put into Cell A1 (format A1 DATE)
What NAME… name put into Cell b1 (format B1 TEXT)
What Amount… amount put into Cell C1 (format C1 $)
Etc. etc.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Thanks.<o:p></o:p>
gregfox<o:p></o:p>
:cool:
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You need an InputBox. Try like this (dates are the trickiest)

Code:
Sub test()
Dim sDate As String
sDate = InputBox("Enter date", "Date Input", Format(Date, "dd/mm/yyyy"))
Range("A1").Value = DateValue(sDate)
End Sub
 
Upvote 0
When I modified the code to:

Sub DateIn()
Dim sDate As String
sDate = InputBox("Enter date", "Date Input", Format(Date, "dd/mm/yyyy"))
Range("A1").Value = DateValue(sDate)
Dim sTest As String
sTest = InputBox("Enter Derivitive", "Text Input", Format(Text))
Range("B1").Value = TestValue(sStock)
End Sub


^^^
TestValue was highlited and I received a Compiler error: Sub or Function not defined.
 
Upvote 0
Welcome to the Board!

Unless you've done so somewhere else, you haven't set either of these as variables:

TestValue(sStock)

So VBA doesn't know what they are.

And with your Input Box, it should probably be Range("B1").Value = sTest

HTH,
 
Upvote 0
I tried:

Sub DateIn()
Dim sDate As String
sDate = InputBox("Enter date", "Date Input", Format(Date, "dd/mm/yyyy"))
Range("A1").Value = DateValue(sDate)

Dim sTest As String
sTest = InputBox("Enter Derivitive", "Text Input", Format(Text))
Range("B1").Value = sTest(sStock)
End Sub

But I get sTest highlighted Compiler error: Expected array.
Sorry I don't yet get it....
 
Upvote 0
Try

Code:
Sub test()
Dim sDate As String, sName As String, sCurrency As String
sDate = InputBox("Enter date", "Date Input", Format(Date, "dd/mm/yyyy"))
sName = InputBox("Enter name")
sCurrency = InputBox("Enter value (number only)")
Range("A1").Value = DateValue(sDate)
Range("B1").Value = sName
With Range("C1")
    .NumberFormat = "$0,000.00"
    .Value = Val(sCurrency)
End With
End Sub
 
Upvote 0
I just got it, with:
Sub DateIn()
Dim sDate As String
sDate = InputBox("Enter date", "Date Input", Format(Date, "dd/mm/yyyy"))
Range("A1").Value = DateValue(sDate)
Dim sTest As String
sTest = InputBox("Enter Derivitive", "Text Input", Format(Text))
Range("B1").Value = sTest
End Sub

Can you explain why on A1 one uses: Range("A1").Value = DateValue(sDate)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
But on B1 I had to use: Range("B1").Value = sTest<o:p></o:p>
Why is DateValue(sDate) vs. sTest, <o:p></o:p>
and not<o:p></o:p>
DateValue(sDate) vs. DateValue(sTest)?<o:p></o:p>
Thanks!
 
Upvote 0
See my post here http://www.mrexcel.com/forum/showpost.php?p=2684341&postcount=7

An InputBox returns Text. If you don't want a text value then you need to do a conversion - DateValue for dates, Val for numbers (or currency).

Note that my code has no error checking - that can be built in as well.

If you want to keep requesting this type of information a userform with 3 textboxes and a Submit button would be more user friendly.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,253
Members
452,900
Latest member
LisaGo

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