Hi everyone i just started a vba class, I have a work to finish before friday and i'm not able to do so.
Here you have the work that i shall to do:
Quote
In the same workbook, write a VBA subroutine to the next treatment.
• With InputBox, enter a value as it is not a number between 1 and 5.
• Suppose that the number is 3, then display in a MsgBox
1
1 2
1 2 3
• For any number i:
1
1 2
...
1 2 3 ... i
• After this display, ask, with a MsgBox if the user wants to start over with another number.
o If yes, repeat the treatment.
o If no, the subroutine ends.
So I start the code but i'm not able to do the last stage.
Code
Sub exercise2()
Dim number As String
Dim a As Single
Dim nb As Single
number = InputBox("Enter a number")
If Not IsNumeric(number) Then
MsgBox ("This is not a number")
End If
Select Case number
Case 1 To 5
MsgBox ("invalid number")
End Select
nb = CSng(number)
For nb = 1 To number Step 1
MsgBox ("" & nb)
Next nb
End Sub
Thank you for your help it's very appreciated.