LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 25
Default Sumeif macro with range selection



"Bob Phillips" wrote:

Dim NextRow As Long
Dim EndRow As Long
Dim LastRow As Long
Dim SumRange As Range
Dim CriteriaRange As Range
Dim NewSum As Double

NextRow = 2
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Do While Cells(NextRow, "A").Value < ""
EndRow = Cells(NextRow, "A").End(xlDown).Row
Set SumRange = Range(Cells(NextRow, "A"), Cells(EndRow, "A"))
Set CriteriaRange = Range(Cells(NextRow, "B"), Cells(EndRow, "B"))
NewSum = Application.SumIf(CriteriaRange, "=20", SumRange)
MsgBox "Sum starting in row " & NextRow & " is " & NewSum

NextRow = EndRow + 1
If NextRow < LastRow Then
Do While Cells(NextRow, "A").Value = ""
NextRow = NextRow + 1
Loop
End If
Loop

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"orquidea" wrote in message
...
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




 
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
Range selection Naveen Excel Discussion (Misc queries) 3 October 9th 07 02:34 PM
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Range Selection cfspahn24 Excel Discussion (Misc queries) 3 April 14th 06 01:29 PM
Selection Range ch Excel Discussion (Misc queries) 5 July 15th 05 05:50 AM


All times are GMT +1. The time now is 03:53 PM.

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

About Us

"It's about Microsoft Excel"