Efface le contenu d'une cellule
Bonjour a tous
voici un petit problème du moins pour moi
j'ai macro qui ouvre et ferme plusieurs feuil(par bouton)
qui fonctionne très bien
Sub ouvrir_feuil()
Dim feuilles, f%
Sheets("recherche emp").SpinButton1.Visible = False 'Rend invisible la toupie
feuilles = Split("base;nouvelle ref;recherche emp;recherche ref;acceuil", ";")
On Error GoTo errfeuil
f = CInt(Right(Application.Caller, 1))
Select Case f
Case 1 To 5
Application.ScreenUpdating = False
If f = 5 Then
ActiveSheet.Visible = False
Sheets("nouvelle ref").Range("B8,D8,F8,H8").ClearContents
With Sheets("recherche emp")
.Protect
.Range("D12,F12,H12,J12,L12,N12,P12,E17").ClearContents
.Unprotect DrawingObjects:=False, Contents:=True, Scenarios:=True
End With
With Sheets("recherche ref")
.Unprotect
Sheets("recherche ref").Range("D12,F12,H12,J12,L12,N12,P12,E17").ClearContents
.Unprotect DrawingObjects:=False, Contents:=True, Scenarios:=True
End With
End If
With Worksheets(feuilles(f))
.Visible = True
.Activate
End With
Application.ScreenUpdating = True
Case Else
Exit Sub
End Select
errfeuil:
End Sub
Edit : merci de mettre le code entre balises avec le bouton </>
mais je voudrais la modifier
et y rajouter
efface le contenu de la cellule E17 quand je ferme la feuil "recherche emp"
efface le contenu de la cellule D12 quand je ferme la feuil "recherche ref"
merci par avance pour vos idées
aiglon74
A
Bonjour,
Votre macro modifiée
Sub ouvrir_feuil() 'Aiglon74
Dim feuilles, f%
Sheets("recherche emp").SpinButton1.Visible = False 'Rend invissible la toupie
feuilles = Split("base;nouvelle ref;recherche emp;recherche ref;acceuil", ";")
On Error GoTo errfeuil
f = CInt(Right(Application.Caller, 1))
Select Case f
Case 1 To 5
Application.ScreenUpdating = False
If f = 5 Then
If ActiveSheet.Name = "recherche emp" Then
Range("E17").ClearContents
ElseIf ActiveSheet.Name = "recherche ref" Then
Range("D12").ClearContents
End If
ActiveSheet.Visible = False
Sheets("nouvelle ref").Range("B8,D8,F8,H8").ClearContents
With Sheets("recherche emp")
.Protect
.Range("D12,F12,H12,J12,L12,N12,P12,E17").ClearContents
.Unprotect DrawingObjects:=False, Contents:=True, Scenarios:=True
End With
With Sheets("recherche ref")
.Unprotect
Sheets("recherche ref").Range("D12,F12,H12,J12,L12,N12,P12,E17").ClearContents
.Unprotect DrawingObjects:=False, Contents:=True, Scenarios:=True
End With
End If
With Worksheets(feuilles(f))
.Visible = True
.Activate
End With
Application.ScreenUpdating = True
Case Else
Exit Sub
End Select
errfeuil:
'ActiveWorkbook.Save 'enregistre en quittant la feuil
End Sub
c'est cette partie là qui a été ajoutée, juste après "If f = 5 Then"
If ActiveSheet.Name = "recherche emp" Then
Range("E17").ClearContents
ElseIf ActiveSheet.Name = "recherche ref" Then
Range("D12").ClearContents
End If
Cdlt
Bonjour Arturo83
je te remercie pour ta réponse
efficace ca marche super bien pour moi
merci de partager tes connaissances
bonne journée
aiglon74