I have a question about VBA in Excel macro. I prepared a macro for a new worksheet but now my supervisor wants to create it into a template. Before my supervisor task everything works fine but when i made a template and run a macro i have a error 09 subscript out of range on template in that piece of code

```
For i = StartZakres To StopZakres
    Dim Dates As New Scripting.Dictionary
    Data = i
    Dates.Add Data, ""
Debug.Print Dates.Keys(Data)
Next i

```

I don't know where is the problem wihout template everything is working. Can u explain me where is the problem ?

Thanks,
David