Bonjour
je souhaite affecter en VBA a la cellule D18 la formule suivante :
	
	
	
	
	
		
Svp comment je peux remplacer la dernier ligne (17) par la variable LastRow pour rendre ma formule flexible.
	
	
	
	
	
		
	
	
	
	
	
		
Salutation
	
		
			
		
		
	
				
			je souhaite affecter en VBA a la cellule D18 la formule suivante :
		VB:
	
	
	=SOMME.SI(A2:A17;A1;D2:D17)
	
		Code:
	
	
	Sub Somme_si_flexible_Formula2Local()
Dim LastRow As Long
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 4).End(xlUp).Row
Range("D" & LastRow + 1).Formula2Local = "=SOMME.SI(A2:A17;A1;D2:D17)"
End Sub
	
		Code:
	
	
	Sub Somme_si_flexible_FormulaR1C1()
Dim LastRow As Long
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 4).End(xlUp).Row
Range("D" & LastRow + 1).FormulaR1C1 = "=SUMIF(R[-16]C[-3]:R[-1]C[-3],R[-17]C[-3],R[-16]C:R[-1]C)"
End Sub
	Salutation