|
以下代码为修改sheet1---sheet10工作表名称为b2单元格值,但是如果中间没有sheet4,程序只执行1-3修改,后面的5-10就不执行了怎么办?
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sheet1.Cells(2, 2) <> "" Then
Sheet1.Name = Sheet1.Cells(2, 2)
End If
If Sheet2.Cells(2, 2) <> "" Then
Sheet2.Name = Sheet2.Cells(2, 2)
End If
If Sheet3.Cells(2, 2) <> "" Then
Sheet3.Name = Sheet3.Cells(2, 2)
End If
If Sheet4.Cells(2, 2) <> "" Then
Sheet4.Name = Sheet4.Cells(2, 2)
End If
If Sheet5.Cells(2, 2) <> "" Then
Sheet5.Name = Sheet5.Cells(2, 2)
End If
If Sheet6.Cells(2, 2) <> "" Then
Sheet6.Name = Sheet6.Cells(2, 2)
End If
If Sheet7.Cells(2, 2) <> "" Then
Sheet7.Name = Sheet7.Cells(2, 2)
End If
If Sheet8.Cells(2, 2) <> "" Then
Sheet8.Name = Sheet8.Cells(2, 2)
End If
If Sheet9.Cells(2, 2) <> "" Then
Sheet9.Name = Sheet9.Cells(2, 2)
End If
If Sheet10.Cells(2, 2) <> "" Then
Sheet10.Name = Sheet10.Cells(2, 2)
End If
End Sub
|
|