J joon49 XLDnaute Nouveau 16 Mai 2023 #1 bonjour, je voudrais en vba mettre une fonction sommeprod: exemple : If Month(Date) = "5" Then cells(5,1)=sommeprod(.....) Else Cells(5, 1) = "" End If comment dois je procéder? merci par avance
bonjour, je voudrais en vba mettre une fonction sommeprod: exemple : If Month(Date) = "5" Then cells(5,1)=sommeprod(.....) Else Cells(5, 1) = "" End If comment dois je procéder? merci par avance
Solution sylvanu 16 Mai 2023 Bonjour Joon, Phil, Ou encore : VB: Sub Essai() If Month(Date) = 5 Then Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) ' A adapter Else Cells(5, 1) = "" End If End Sub NB: Pas de parenthèses autour de 5 car "Month" renvoie un nombre.
Bonjour Joon, Phil, Ou encore : VB: Sub Essai() If Month(Date) = 5 Then Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) ' A adapter Else Cells(5, 1) = "" End If End Sub NB: Pas de parenthèses autour de 5 car "Month" renvoie un nombre.
Phil69970 XLDnaute Barbatruc 16 Mai 2023 #2 Bonjour @joon49 Je te propose If Month(Date) = 5 Then [A5] = Evaluate("SumProduct((B2:B4)*(C2:C4))") 'Ta formule somme Prod Else [A5] = "" End If Cliquez pour agrandir... Merci de ton retour @Phil69970 Dernière édition: 16 Mai 2023 Vote positif 0 Vote négatif
Bonjour @joon49 Je te propose If Month(Date) = 5 Then [A5] = Evaluate("SumProduct((B2:B4)*(C2:C4))") 'Ta formule somme Prod Else [A5] = "" End If Cliquez pour agrandir... Merci de ton retour @Phil69970
sylvanu XLDnaute Barbatruc Supporter XLD 16 Mai 2023 #3 Bonjour Joon, Phil, Ou encore : VB: Sub Essai() If Month(Date) = 5 Then Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) ' A adapter Else Cells(5, 1) = "" End If End Sub NB: Pas de parenthèses autour de 5 car "Month" renvoie un nombre. Vote positif 0 Vote négatif Solution
Bonjour Joon, Phil, Ou encore : VB: Sub Essai() If Month(Date) = 5 Then Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) ' A adapter Else Cells(5, 1) = "" End If End Sub NB: Pas de parenthèses autour de 5 car "Month" renvoie un nombre.
Staple1600 XLDnaute Barbatruc 16 Mai 2023 #5 Bonsoir le fil Pour les Ifophobes Code: Sub Essai_Ter() Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) * -(Month(Date) = 5) End Sub Vote positif 0 Vote négatif
Bonsoir le fil Pour les Ifophobes Code: Sub Essai_Ter() Cells(5, 1) = Application.SumProduct([A1:A4], [B1:B4]) * -(Month(Date) = 5) End Sub