daulpuchich
New Member
- Joined
- Jun 22, 2015
- Messages
- 36
Hello i'm new to VBA and i'm not quite sure if you can use VBA to program more than one cell or not. I've read multiple resources saying you can and that you cannot.
In this case i'm trying to create an input box where it will only accept a number that is greater than or equal to 2. Within the input box, there will be OK and CANCEL.
if the user clicks OK then the cells in column B starting at B2 would be filled in with the respective row number up to the row that was inputted by the user.
Whereas if the user clicks CANCEL then A1 will become the active cell.
I have;
Private Sub CommandButton1_Click()
Range("B10").Value = "I am here"
Dim x As Variant
' Run the Input Box.
x = InputBox("Dukes Input Box")
Msg = "Enter a number Equal or Greater than 2"
If x >= 2 Then Range("B2").Value = x
' if Cancel was pressed.
Range("A1").Activate
End Sub
This is what it would look like if the user inputted 6.
In this case i'm trying to create an input box where it will only accept a number that is greater than or equal to 2. Within the input box, there will be OK and CANCEL.
if the user clicks OK then the cells in column B starting at B2 would be filled in with the respective row number up to the row that was inputted by the user.
Whereas if the user clicks CANCEL then A1 will become the active cell.
I have;
Private Sub CommandButton1_Click()
Range("B10").Value = "I am here"
Dim x As Variant
' Run the Input Box.
x = InputBox("Dukes Input Box")
Msg = "Enter a number Equal or Greater than 2"
If x >= 2 Then Range("B2").Value = x
' if Cancel was pressed.
Range("A1").Activate
End Sub
This is what it would look like if the user inputted 6.