Input Box

Phoenix333

New Member
Joined
Sep 28, 2010
Messages
26
I don't know much (anything, really) about VB, but I'm usually pretty good and finding relevant code online and adjusting it to my needs; but today, my brain is not cooperating. Please help :)

I have a worksheet and in cell B2, there is a data validation list, allowing the user to select either Yes or No. If the use selects Yes, I'd like an input box to pop up and ask "How many rounds are needed for this project?" at which point, the user can enter a number. That number will then populate Cell C2.

The last code I ended up trying is:

Sub Round()
Dim Rounds As Integer

If Range("B2").Value = "Yes" Then
Rounds = inputbox("How many Rounds are in this project?", Rounds)
Range("C2").Value = Rounds
End If
End Sub

Can anyone help?

Thanks so much!
T-
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this and see if it works:

Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim iValue As Integer
Dim rValue As Range

Set rValue = Sheets("Sheet1").Range("B2")

If Target.Cells = rValue Then
    If Target.Value = "Yes" Then
        iValue = InputBox("How many rounds are in this project?", rounds)
        Range("C2").Value = iValue
    End If
End If
End Sub
 
Upvote 0
Code:
Sub test()
If Range("B2").Value = "Yes" Then
    roundsneeded = InputBox("How Many Rounds Are Needed For This Project", "")
    Range("C2").Value = roundsneeded
End If
End Sub

This only looks for "Yes" in cell B2, if you want "yes", you can make the appropriate change in line 2
 
Upvote 0
Once I got my head out of the clouds and changed the sheet1 to the actual name of my sheet, it worked beautifully! Thank you so much!

:laugh:
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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