View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
excelent excelent is offline
external usenet poster
 
Posts: 695
Default Sumeif macro with range selection

Sub SumIf20()
x = Cells(65500, "A").End(xlUp).Row
y = Application.SumIf(Range("B1:B" & x), "=20", Range("A1:A" & x))
MsgBox y
End Sub


"orquidea" skrev:

Hi:

I am trying to do a macro wich works with sumif in a range selected and
after that look for the next active cell, select the range and work again
with the sumif formula.
This is what I have so far:

Range("A2").Select
Selection.End(xlDown).Select

FirstRow= I don't know how to define this one,
LastRow=Cells(Rows.Count,"A").End(xlup).Row
Set criteriarange=Range( I don' know & LastRow)
Setsumrange(Range(I don't know &LastRow)
Newsum=WorksheetFunction.Sumif(Criteriarange,"=20" ,sumrange)

The ranges will be like below
6 40
1 40
4 40


2 20
1 40
84 40


6 40
3 40
5 40

Could anyone help me please? It would be greatly appreciated.

Thanks
Orquidea