Refer to sheet using codename
问题 I get a \"type mismatch\" error in this code: With Worksheets(Sheet1) \'* Error here \'my code here End With My sheet\'s CodeName is \'sheet1\' . Can someone please help me remove the error? 回答1: 1) Refer to sheet by Index: With Worksheets(1) '<stuff here> End With The `Index' is dependent on the "order of sheets in the workbook". If you shuffle your sheets order, this may not refer to the same sheet any more! 2) Refer to sheet by Name: With Worksheets("Your Sheet Name") '<stuff here> End