Input Box help Please

bloodmilksky

Board Regular
Joined
Feb 3, 2016
Messages
202
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.

Code:
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?
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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.

Code:
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 [B][COLOR="#FF0000"]InputBox ("Please enter Account Number Or Postcode")[/COLOR][/B]
    Range("E3").Value = myValue
End Sub

Could anyone help please?
You are not assigning the user's input to the myValue variable.
 
Last edited:
Upvote 0
So should it be something like

Range("E3") = MyValue?

Sorry rick I am still learning how to type out alot of this
You wrote this...

If Ans = vbYes Then InputBox ("Please enter Account Number Or Postcode")

You should have written this instead...

If Ans = vbYes Then MyValue = InputBox ("Please enter Account Number Or Postcode")

If you don't put the user's input into the MyValue variable, then there won't be anything in the variable when you try to assign it to cell E3.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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