AS
VBA per Microsoft Excel
Crea, rinomina ed elimina fogli di lavoro
Crea un nuovo foglio. Rinomina il foglio attivo. Elimina il foglio attivo, se non è l'unico.
Public Sub NewSheet()
Sheets.Add After:=Sheets(Sheets.Count)
End Sub
Public Sub DelSheet()
If Sheets.Count > 1 Then
ActiveSheet.Delete
Else
MsgBox ("La cartella contiene un solo foglio!")
End If
End Sub
Public Sub RenameSheet()
Dim i As Integer
Dim n As String
i = 1
n = InputBox("Rinomina foglio", "Nuovo nome:", ActiveSheet.Name)
While i < Sheets.Count
If n = Sheets(i).Name Then
MsgBox ("Esiste già un foglio con quel nome")
Exit Sub
End If
i = i + 1
Wend
If IsNull(n) = False And n <> "" Then
ActiveSheet.Name = n
End If
End Sub