Returning MsgBox/User Form Entries to Worksheet

SolarSpence

New Member
Joined
Jun 7, 2011
Messages
2
I am trying to take an input from a user and return it to a worksheet for use in calculations.

Ideally, I would like to make a custom message box that returns text or numerical values to a specified worksheet.
Otherwise, a vbYesNo message box that returns a certain text/value to a worksheet based on the users response would work.

Thanks in advance.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I dont know if this is what you are looking for but it is a very simple example of what you asked. Copy and paste to VBE

Code:
Sub InsertValue()
Dim msg As String
Dim location As String

Application.ScreenUpdating = False

msg = InputBox("Please place your value ot text here")
location = InputBox("Enter the cell that you want to house your value")

Range(location).Select
Selection.Value = msg

Application.ScreenUpdating = True

End Sub
George

I am trying to take an input from a user and return it to a worksheet for use in calculations.

Ideally, I would like to make a custom message box that returns text or numerical values to a specified worksheet.
Otherwise, a vbYesNo message box that returns a certain text/value to a worksheet based on the users response would work.

Thanks in advance.
 
Upvote 0
Thank you for the help.

This is helpful but what I really need is to have a MsgBox/User Form that has a question with 2 or more options (command buttons). Then when one is selected, that value is entered into a specified cell.

Thanks
 
Upvote 0
Then something like this:

Insert a userform in your VBE add two buttosn and a text box named: cmdAsk - cmdExit - txtEnterValue and then copy paste the following code:

Code:
Option Explicit

Private Sub cmdAsk_Click()
Dim msg As String
Dim location As String

msg = MsgBox("Do you want to copy the entered value to your worksheet?", vbYesNo)

If msg = 6 Then
    location = InputBox("Enter the cell that you want to house your value")
    Worksheets("Sheet1").Range(location).Select
    Selection.Value = txtEnterValue.Text
Else
txtEnterValue.SetFocus
End If
End Sub

Private Sub cmdExit_Click()
Unload UserForm1
End Sub
George

Thank you for the help.

This is helpful but what I really need is to have a MsgBox/User Form that has a question with 2 or more options (command buttons). Then when one is selected, that value is entered into a specified cell.

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

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