Hep with Input box - choose between 1 and 1.5 and place into cel

twodoor55

New Member
Joined
Jan 6, 2008
Messages
16
I am looking for a macro/formula to place into an input box, I want the user to choose either .5 or 1. I then want that number to be placed in cell A3. I know it sounds easy, but can't figure it out. Maybe it needs to be a different choice?
 

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.
I am looking for a macro/formula to place into an input box, I want the user to choose either .5 or 1. I then want that number to be placed in cell A3. I know it sounds easy, but can't figure it out. Maybe it needs to be a different choice?
Maybe an approach like this?
Code:
Sub Test()
  Dim Answer As Variant
  Do
    Answer = Application.InputBox("Please enter either 0.5 or 1.", Type:=1)
    If Answer = 0.5 Or Answer = 1 Or Answer = "False" Then Exit Do
  Loop
  MsgBox "Your input: " & Answer
End Sub
 
Upvote 0
That's strange, I'm not getting any error using the code below. I'm not an excel expert though, so I'm sorry if I caused you additional confusion!

Code:
Sub Test()
  Dim Answer As Variant
  Do
    Answer = Application.InputBox("Please enter either 0.5 or 1.", Type:=1)
    If Answer = 0.5 Or Answer = 1 Or Answer = "False" Then Exit Do
  Loop
  MsgBox "Your input: " & Answer
  
  Sheets("Sheet2").Range("A1").Value = Answer
End Sub
 
Upvote 0
Ack, I figured it out! You need to put "" around the sheet name, ex: Sheets("Sheet1")

I'm really sorry about that!! :(
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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