The code that you provided does not compile. Maybe you were trying to provide a simple example...?
It does not compile because Input
is a reserved word, used to read data from a file object. You cannot use it as a variable name. (I have assumed that "xxxxx" is indicating where code should go, i.e. 'Do something here
.)
The following code works, but you cannot run it without passing a value:
Sub do_something(i As Integer)
MsgBox i
End Sub
If you want to make the variable optional, you can add the Optional
keyword. Then it will run even if a value is not passed:
Sub do_something(Optional i As Integer)
MsgBox i
End Sub
You could also use a globally scoped variable, which would allow the sub to run without directly supplying a value:
Option Explicit
Public i As Integer
Sub do_something()
MsgBox i
End Sub
Regarding Input
: https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/inputstatement