PB VBA
tiger202020
-
gbinforme Messages postés 14946 Date d'inscription Statut Contributeur Dernière intervention -
gbinforme Messages postés 14946 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
J'ai besoin de modifier une macro en VBA (Non écrite par moi...).
Je voudrais rajouter une condition sur la ligne :
F.[T1].FormulaR1C1 = "=SUMIF(R2C5:R" & DerLig & "C5,""Y"",R2C13:R" & DerLig & "C13)"
-> Calcul à faire uniquement pour les cellules ou il y a l'année 2017 dans la colonne C de ma feuille "Data"
Merci de votre aide !
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim F As Worksheet, PlgM As Range, DerLig As Long
If Application.CutCopyMode <> 0 Then Exit Sub
Set F = Sh
If F.Name = "Data" Then Exit Sub
If F.Name = "Stats" Then Exit Sub
If F.Name = "Report" Then Exit Sub
If F.Name = "Stats" Then Exit Sub
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
F.[A2:S50000].Delete xlShiftUp
With Intersect(Feuil1.[S2:S50000], Feuil1.UsedRange)
.FormulaR1C1 = "=1/(RC10=""" & F.Name & """)"
On Error Resume Next
Set PlgM = .SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Not PlgM Is Nothing Then Intersect(Feuil1.[A:S], PlgM.EntireRow).Copy F.[A2]
.ClearContents
End With
Feuil1.[S2:S4].Copy F.[S2:S4]
DerLig = F.UsedRange.Rows.Count
F.[T1].FormulaR1C1 = "=SUMIF(R2C5:R" & DerLig & "C5,""Y"",R2C13:R" & DerLig & "C13)"
Application.Calculation = xlCalculationAutomatic
End Sub
J'ai besoin de modifier une macro en VBA (Non écrite par moi...).
Je voudrais rajouter une condition sur la ligne :
F.[T1].FormulaR1C1 = "=SUMIF(R2C5:R" & DerLig & "C5,""Y"",R2C13:R" & DerLig & "C13)"
-> Calcul à faire uniquement pour les cellules ou il y a l'année 2017 dans la colonne C de ma feuille "Data"
Merci de votre aide !
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim F As Worksheet, PlgM As Range, DerLig As Long
If Application.CutCopyMode <> 0 Then Exit Sub
Set F = Sh
If F.Name = "Data" Then Exit Sub
If F.Name = "Stats" Then Exit Sub
If F.Name = "Report" Then Exit Sub
If F.Name = "Stats" Then Exit Sub
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
F.[A2:S50000].Delete xlShiftUp
With Intersect(Feuil1.[S2:S50000], Feuil1.UsedRange)
.FormulaR1C1 = "=1/(RC10=""" & F.Name & """)"
On Error Resume Next
Set PlgM = .SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Not PlgM Is Nothing Then Intersect(Feuil1.[A:S], PlgM.EntireRow).Copy F.[A2]
.ClearContents
End With
Feuil1.[S2:S4].Copy F.[S2:S4]
DerLig = F.UsedRange.Rows.Count
F.[T1].FormulaR1C1 = "=SUMIF(R2C5:R" & DerLig & "C5,""Y"",R2C13:R" & DerLig & "C13)"
Application.Calculation = xlCalculationAutomatic
End Sub