|It's like I said in my previous post...with a twist:|
If you have 2013 in Q1, the variable shtname is getting set to a number: 2013. Then when you use
VBA is looking for Sheets(2013). Since you don't have 2013 sheets in your workbook, the code fails.
When you change Q1 to Y2013, a text string is returned and VBA is looking for Sheets("Y2013").
If you must use 2013, then you must tell VBA to use the text string "2013" not the number 2013:
shtname = Cstr(Sheets("DASHBOARD").Range("Q1"))
See here for other Type Conversion Functions:
BTW...You might find the following tutorial helpful. By using the techniques described, you can Single Step through your code and Watch the variables to see what they get set to. That can be very helpful when troubleshooting code. It's beats clicking Run over and over again and trying to figure how why the code fails each time.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.