I dot know why, Excel throws an error at this line:
Dim yearnr As Integer = 18
I want to declare a variable and assign a initial value. Please tell me why it is not working.
I dot know why, Excel throws an error at this line:
Dim yearnr As Integer = 18
I want to declare a variable and assign a initial value. Please tell me why it is not working.
In VBA the above format is not possible
only constants can be used like this :
Const yearnr As Integer = 18
you can use
Dim yearnr As Integer
yearnr = 18
Public yearnr As Integer
yearnr = 18
Excel doesn't let you initialize values at declaration as they're already initialized to zero. To do what you want just break it up into two lines.
Dim yearnr As Integer
yearnr = 18
Looking at the Question in my comment, For you needs it would be:
Dim yearnr As Integer: yearnr = 18
you can make it one line with the :
character