VBA - Input Box

Puppies72

Board Regular
Joined
Mar 29, 2010
Messages
211
Hi all,

I am using the following code to get a number from the user.

Code:
Sub UserInput()
Dim i As Variant
InputBoxInit:
    i = Application.InputBox(Prompt:="Generate Player Report for Player?", Title:="Enter Player Number", Type:=1)
    If IsNumeric(i) Then
        If i >= 1 And i <= 15 Then
            Sheets("Report Test").Range("I1").Value = i
        Else
            MsgBox "Please enter a value between 1 and 15."
            GoTo InputBoxInit
        End If
    End If

I need to change cells in several sheets to this value - how do I do it? The same cells will always be the one changed I just need to change the value to whatever the user entered e.g. Validator!C2, Economics!B1 both need to be changed to the entered value

As always help appreciated!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Just add the additional Sheets/Ranges like this:
Code:
Sub UserInput()
Dim i As Variant
InputBoxInit:
    i = Application.InputBox(Prompt:="Generate Player Report for Player?", Title:="Enter Player Number", Type:=1)
    If IsNumeric(i) Then
        If i >= 1 And i <= 15 Then
            Sheets("Report Test").Range("I1").Value = i
            Sheets("Validator").Range("C2").Value = i
            Sheets("Economics").Range("B1").Value = i
        Else
            MsgBox "Please enter a value between 1 and 15."
            GoTo InputBoxInit
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,274
Members
452,902
Latest member
Knuddeluff

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