View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
JE McGimpsey
 
Posts: n/a
Default Need help with VBA

I'm not sure why you can't just use a formula:

=SUMIF(Sheet2!A:A,"David",Sheet2!B:B)

In VBA you could do the same using

Public Sub Commandbutton1_Click()
With Worksheets("Sheet2")
ActiveCell.Value = Application.SumIf( _
.Columns(1).Cells, "David", .Columns(2).Cells)
End With
End Sub




In article ,
Need help with sumif
wrote:

I'm not sure If I could explain this easy but let me try


on sheet1 there are name list
on sheet2 there are list of names with their earning in $(Name could appear
more than once)
on sheet3 I want to find all cells that contains (David) & what ever $
that's next to it add it when I click a command button

If this doesn't explain enough maybe I could attach the sample let me know
Thanks !!!!