View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Gary Paris[_2_] Gary Paris[_2_] is offline
external usenet poster
 
Posts: 8
Default Incredible code ! Thanks

Wow,

You did in two lines what it took me many lines and quite a few hours to
figure out. Thanks for the great code snippit. Plus, the sheets don't get
selected and the active cell isn't changed. I still have
lots to learn, but I guess that is what the newsgroups are all about!

Gary

"Don Wiss" wrote in message
...
On Fri, 24 Dec 2004 17:08:00 -0800, Gary Paris wrote:

Sheets("Expenses").Select

For Each myCell In Range("Paid_By").Cells
Range(myCell.Address).Select

Select Case myCell

Case "Gary"
Gary_Total = Gary_Total + ActiveCell.Offset(0, -2).Value

Case "Dom"
Dom_Total = Dom_Total + ActiveCell.Offset(0, -2).Value

End Select

Next myCell



This is how I would do this. No sheet selection needed.

Gary_Total =
WorksheetFunction.SumIf(Range("Paid_By"),"Gary",Ra nge("Paid_By").Offset(0,-2))
Dom_Total =
WorksheetFunction.SumIf(Range("Paid_By"),"Dom",Ran ge("Paid_By").Offset(0,-2))

Don <donwiss at panix.com.