I have a worksheet labeled '2008'
If SelectedYear = 2008 Then
Oldswitch = Sheets(SelectedYear).Visible
Sheets(SelectedYear).Visible = True
Sheets(SelectedYear).Select
End If
what I want to do is if a variable (SelectedYear) = 2008 then execute the code above. I know i am missing the quotations required to reference the worksheets as
If SelectedYear = 2008 Then
Oldswitch = Sheets("2008").Visible
Sheets("2008").Visible = True
Sheets("2008").Select
End If
works fine. What would be the correct syntax to do what I am looking to do? I would like to structure it this way as I have many years worth of worksheets to code for this way and I am looking to reduce the number of Sheets("n") to code
Bookmarks