Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro with sumif
Hi:
I want to set a macro which will work with the sumif formula below. The range (B1:B3 and A1:A3) will be relative every time and would vary the number of rows subject to be considered. I think I will have to select the range first with Selection.End(xlDown).Select. But I can not figure out how to code it. =SUMIF(B1:B3,20,A1:A3) Thanks in advance for any help. Orquidea |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro with sumif
One way
Sub dosumif() criteria = 1 lr = Cells(Rows.Count, "n").End(xlUp).Row Set cr = Range("n1:n" & lr) Set sr = Range("o1:o" & lr) MsgBox Application.SumIf(cr, criteria, sr) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "orquidea" wrote in message ... Hi: I want to set a macro which will work with the sumif formula below. The range (B1:B3 and A1:A3) will be relative every time and would vary the number of rows subject to be considered. I think I will have to select the range first with Selection.End(xlDown).Select. But I can not figure out how to code it. =SUMIF(B1:B3,20,A1:A3) Thanks in advance for any help. Orquidea |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro with sumif
Thanks for your help
"Don Guillett" wrote: One way Sub dosumif() criteria = 1 lr = Cells(Rows.Count, "n").End(xlUp).Row Set cr = Range("n1:n" & lr) Set sr = Range("o1:o" & lr) MsgBox Application.SumIf(cr, criteria, sr) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "orquidea" wrote in message ... Hi: I want to set a macro which will work with the sumif formula below. The range (B1:B3 and A1:A3) will be relative every time and would vary the number of rows subject to be considered. I think I will have to select the range first with Selection.End(xlDown).Select. But I can not figure out how to code it. =SUMIF(B1:B3,20,A1:A3) Thanks in advance for any help. Orquidea |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro with sumif
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set criteriarange = Range("B1:B" & LastRow) Set sumrange = Range("A1:A" & LastRow) newsum = WorksheetFunction.SumIf(criteriarange, "=20", sumrange) "orquidea" wrote: Hi: I want to set a macro which will work with the sumif formula below. The range (B1:B3 and A1:A3) will be relative every time and would vary the number of rows subject to be considered. I think I will have to select the range first with Selection.End(xlDown).Select. But I can not figure out how to code it. =SUMIF(B1:B3,20,A1:A3) Thanks in advance for any help. Orquidea |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro with sumif
Thanks Joel for your help.
"Joel" wrote: LastRow = Cells(Rows.Count, "A").End(xlUp).Row Set criteriarange = Range("B1:B" & LastRow) Set sumrange = Range("A1:A" & LastRow) newsum = WorksheetFunction.SumIf(criteriarange, "=20", sumrange) "orquidea" wrote: Hi: I want to set a macro which will work with the sumif formula below. The range (B1:B3 and A1:A3) will be relative every time and would vary the number of rows subject to be considered. I think I will have to select the range first with Selection.End(xlDown).Select. But I can not figure out how to code it. =SUMIF(B1:B3,20,A1:A3) Thanks in advance for any help. Orquidea |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" | Excel Worksheet Functions | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Embedding a Sumif in a sumif | Excel Worksheet Functions | |||
nested sumif or sumif with two criteria | Excel Worksheet Functions | |||
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function | Excel Worksheet Functions |