LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Sumif Range to new Worksheet

I am trying to summarize Purchase Orders by Project and Vendor
from POSummary into VendorSummary
..
Source WorkSheet POSummary
A B C D
Project PO# Vendor PO Value
693 56 Alpha 1,000
693 50 Alpha 2,000
693 54 Bravo 1,000
231 13 Charlie 4,000
231 33 Charlie 2,000
231 23 Bravo 3,000
231 49 Alpha 3,000
231 12 Alpha 5,000
.....
Expected result inDestination VendorSummary
A B C
Project Vendor PO Value
693 Alpha 3,000
693 Bravo 1,000
231 Charlie 6,000
231 Bravo 3,000
231 Alpha 8,000

Somehow, I must have my i's & j's indexes crossed
but I canot find my error.
Help appreciated.
J.P.

Sub Vendor()

Dim i As Integer ' Source Worksheet Current Row Counter
Dim j As Integer ' Criteria Range Counter
Dim k As Integer ' Destination Worksheet Current Row Counter
Dim RngC As Range ' Vendor Range
Dim RngD As Range ' PO Value Range
'
'Sort Source WorkSheet by Project & Vendor
Columns("A:D").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Key2:=Range("C2"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom
'
i = 2: k = 2 ' Data start in Row2
Set RngC = Range(Cells(1, "C"), Cells(Rows.Count, "C").End(xlUp))
Set RngD = Range(Cells(1, "D"), Cells(Rows.Count, "D").End(xlUp))

' Calculate Sums by Vendor in VendorSummary
Do While i <= Range("A65000").End(xlUp).Row
j = Application.CountIf(RngC, Cells(i, "C"))
Worksheets("VendorSummary").Cells(k, "A") = Cells(i, "A") '
Project Code
Worksheets("VendorSummary").Cells(k, "B") = Cells(i, "C") ' Vendor
Name
Worksheets("VendorSummary").Cells(k, "C") =
Application.SumIf(RngD, Cells(i, "C"), RngD)
k = k + 1: i = i + j
Loop

End Sub



 
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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
SumIf - when I fill down the Range, Criteria & sum range changes markholt Excel Worksheet Functions 3 October 28th 08 12:37 AM
Sort Worksheet Range from another worksheet range, Excel 2000 & 2003 jfcby[_2_] Excel Programming 1 August 21st 07 02:55 AM
How to use a range in SUMIF? bdddd Excel Worksheet Functions 7 February 14th 06 06:44 PM
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 07:54 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"