soccerkingpilot
Board Regular
- Joined
- May 21, 2012
- Messages
- 105
Today's not my day :P Here's post number 2...I've created an error handler to create a worksheet if it doesn't exist. It creates the spreadsheet and names it after the year of a date that I've captured. On the line I've marked below, it gives me Run-time Error 9. I know it's catching on the Sheets(ShtName) because I've tested it without everything else and it still snags. I don't understand why it won't find the Sheet named (in this case) 2011 when it used the same variable to create the sheet named 2011.
Thanks,
Austin
Code:
errHandler:On Error Resume Next
If wsTest Is Nothing Then
Set AddSheet = MnS.Worksheets.Add
ShtName = Year(FADate)
AddSheet.Name = ShtName
Set dest = Sheets(ShtName).Range("A1:AZ1") '<---Error happens here
Sheets("2012").Range("A1:AZ1").Copy dest
Cells(1, 1).PasteSpecial
End If
Thanks,
Austin