Bonjour le forum,
J'arrive très bien à rajouter un onglet et à le nommer. Mais je cherche le code qui me préviendrait si le nom que je choisi pour nommer ma nouvelle sheet est déjà le nom d'une sheet existente.
Dans mon exemple, j'utilise un textbox dans lequel l'utilisateur tape le nom de la sheet.
Private Sub CommandButton1_Click()
For n = 1 To Worksheets.Count
If Worksheets(n).Name = TextBox1.Value Then GoTo fini
Sheets.Add.Name = TextBox1.Value
end if
Next n
fini:
Dim Msg, Style, Title, Response
Msg = "You can not rename a sheet to the same name as another sheet"
Style = vbOKOnly + vbInformation + vbDefaultButton2
Title = "Check Sheet Name"
Response = MsgBox(Msg, Style, Title)
SheetName.Hide
End Sub
merci d'avance
David
J'arrive très bien à rajouter un onglet et à le nommer. Mais je cherche le code qui me préviendrait si le nom que je choisi pour nommer ma nouvelle sheet est déjà le nom d'une sheet existente.
Dans mon exemple, j'utilise un textbox dans lequel l'utilisateur tape le nom de la sheet.
Private Sub CommandButton1_Click()
For n = 1 To Worksheets.Count
If Worksheets(n).Name = TextBox1.Value Then GoTo fini
Sheets.Add.Name = TextBox1.Value
end if
Next n
fini:
Dim Msg, Style, Title, Response
Msg = "You can not rename a sheet to the same name as another sheet"
Style = vbOKOnly + vbInformation + vbDefaultButton2
Title = "Check Sheet Name"
Response = MsgBox(Msg, Style, Title)
SheetName.Hide
End Sub
merci d'avance
David