Because you are calling Val() on the factorialInput variable before you even get a value for it from the inputbox, so N I would assume would be 0, which then just skips your loop since it is not greater than 0. You have to convert the input from the InputBox to a number after the user enters it