View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.fr.excel
GD[_2_] GD[_2_] is offline
external usenet poster
 
Posts: 3
Default How to write a VBA code to select certain rows based on certain conditions

Hi houstoncity2004 ;-))
as i understand the simple version of your data :
you can use something like this :

Sub Macro1()
' Macro enregistrée le 24/06/2004 par GeeDee
Range("A2:A100").Name = "Group_no"
Range("C2:C100").Name = "Amount_spent"
'----a loop may be better used for large number of Group No----
Range("G1").Name = "Group1"
Range("G2").Name = "Group2"
Range("G3").Name = "Group3"
Range("G4").Name = "Group4"
Range("Group1").Formula = "=SUMPRODUCT(Amount_spent*(Group_no=1))"
Range("Group2").Formula = "=SUMPRODUCT(Amount_spent*(Group_no=2))"
Range("Group3").Formula = "=SUMPRODUCT(Amount_spent*(Group_no=3))"
Range("Group4").Formula = "=SUMPRODUCT(Amount_spent*(Group_no=4))"
'-----------
End Sub

@+ Modeste(®) GeeDee
HTH
Much more tips and tricks on the best "Excel Addicts" Site in french
language
http://www.excelabo.net