PDA

View Full Version : Trouble with Input Box



bloodmilksky
10-27-2016, 01:48 AM
Hi Guys, I hope you are all well today.

I am trying to use the below for an order form so that the user enters a Post Code Or AC number and this goes into cell E3 where the form will then produce the customers AC details. but for some reason the Value is not going into the Cell after it is being entered.



Sub Would_You_Like_To_Place_An_Order()
Dim myValue As Variant

Msg = "Would You Like To Place An Order ? " & Application.UserName
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End If
If Ans = vbYes Then InputBox ("Please enter Account Number Or Postcode")
Range("E3").Value = myValue
End Sub


Could anyone help please?

GTO
10-27-2016, 02:46 AM
You are not assigning the return of the InputBox to myValue:


Option Explicit

Sub Would_You_Like_To_Place_An_Order()
Dim myValue As String

If MsgBox("Would You Like To Place An Order ? " & Application.UserName, vbYesNo Or vbQuestion, vbNullString) = vbYes Then
myValue = InputBox("Please enter Account Number Or Postcode")
Range("E3").Value = myValue
Else
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit
End If

End Sub


Hope that helps,

Mark

GTO
10-27-2016, 02:56 AM
@bloodmilksky:

Please read http://www.excelguru.ca/content.php?184 reference cross-posting.

Cross-posted at http://www.mrexcel.com/forum/excel-questions/972682-input-box-help-please.html

Mark