[vba][error]run time error 91 object variable or with block
salut,
c est une fonction qui si une feuille avec un nom precis existe alors je le supprime
et j ai ce message erreur:
run time error 91 object variable or with block variable not set
voila mon code peut etre vous verrez mieux que moi le pb
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
Public Sub SheetControlInvoiceExist()
' cette fonction permet de tester si la feuille control inovice existe
Dim mysheet As Worksheet
Dim msg As String ' mon message
Dim reponse
msg = " Une feuille ' Control Invoice ' est déjà voulez vous la supprimer ? ( An Excel sheet already exists ,do you want to delete it ? ) "
If mysheet = Sheets("Control Invoice") Then 'si il y a deja une feuille control invoice
If MsgBox(msg, vbYesNo) = vbYes Then ' le user clic sur yes
Sheets("Control Invoice").Delete
MsgBox (" la feuille Excel 'Control Invoice' a été supprimé avec succès ( The Excel sheet ' Control Invoice 'deleted successful ) ")
Else ' le user a choisit non
End If
Else ' il n y a pas de feuille excel control invoice
End If
End Sub |
merci ;)