#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default 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


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sumif for multi conditions. i.e sumif(A1:A10,"Jon" and B1:B10,"A" Harry Seymour Excel Worksheet Functions 9 June 12th 07 10:47 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Embedding a Sumif in a sumif C.Pflugrath Excel Worksheet Functions 5 August 31st 05 07:31 PM
nested sumif or sumif with two criteria dshigley Excel Worksheet Functions 5 April 5th 05 03:34 AM
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function Oscar Excel Worksheet Functions 2 January 11th 05 11:01 PM


All times are GMT +1. The time now is 09:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"