放在你要放表名的那張工作表的code區塊,不要放錯。
從B2到B65535都會動作,然後必須依序
值更新後就會自動更新
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("B2:B65535")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Sheets.Count >= Target.Row Then
Sheets(Target.Row).Name = Target.Value
ElseIf Sheets.Count = Target.Row - 1 Then
Sheets.Add After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = Target.Value
Me.Activate
Else
MsgBox "請依序輸入"
End If
End If
End Sub