Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2016 Clôturer-This worbook vba

Keran

XLDnaute Junior
Bonjour j'aurais aimer savoir si il etais possible de faire une macro "generique" avec ma macro
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WS As Worksheet
For Each WS In Sheets(Array("Janvier", "HJanvier", "BJanvier", "Bilan"))
WS.Unprotect ("azerty")
WS.Calculate
WS.Protect ("azerty"), DrawingObjects:=True, Contents:=True, Scenarios:=True _
                       , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True
Next WS
End Sub
Pour dans l'idee faire comme mais en worksheet change et non active
VB:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim Cel As Range
Application.ScreenUpdating = False
With Sh
    If .Name = "B" & .Range("A1") Then
        For Each Cel In Sh.Range("B8:CA8")
            If Not IsError(Cel) Then Cel.EntireColumn.Hidden = Cel = ""
        Next Cel
    End If
End With
Application.ScreenUpdating = True
End Sub

merci d'avance
 

Keran

XLDnaute Junior
Bonjour , a l'heure actuel j'ai la première macro qui est dupliquer pour les douze mois j'aimerais savoir si vous pensez qu'il est possible de faire une seul macro qui pourrais gérer les douze mois/feuilles .
Merci encore.
 

Keran

XLDnaute Junior
Je voulais faire une fonction du genre mais je pense me tromper
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim WS As Worksheet
With Sh
For Each WS In Sheets(Array(Sh, ("H" & Sh), ("B" & Sh), "Bilan"))
    If .Name = .Range("A1") Then
WS.Unprotect ("azerty")
WS.Calculate
WS.Protect ("azerty"), DrawingObjects:=True, Contents:=True, Scenarios:=True _
                       , AllowFormattingCells:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True, AllowFiltering:=True


        For Each Cel In Sh.Range("B8:CA8")
            If Not IsError(Cel) Then Cel.EntireColumn.Hidden = Cel = ""
        Next Cel
    End If
End With
End Sub
 
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…