Hi guys,
I am trying to extract data from one sheet which contains multiple entries (sheet 2) into another sheet which will condense these entries into a single row (sheet1).
The relevant rows in sheet 2 are selected with a nested loop based on the group (col. A) and region (col. B) in sheet 1.
My problem: once the appropriate rows are identified in sheet 2, how do i produce their sum in sheet 1?
I have attached a sample book, highlighted in yellow (pallet permitting) the matching columns in sheet 2 that I would like to extract into sheet 1.
Sub xyz()
Dim source_range As Range, target_range As Range
Dim source_counter As Integer, target_counter As Integer
Dim source_records As Integer, target_records As Integer
Set source_range = Sheets(1).Range("B2", Range("B" & Rows.Count).End(xlUp))
Set target_range = Sheets(2).Range("B2", Range("B" & Rows.Count).End(xlUp))
source_records = source_range.Rows.Count - 1
target_records = target_range.Rows.Count - 1
For source_counter = 0 To source_records
For target_counter = 0 To target_records
If (source_range(source_counter + 1) = target_range(target_counter + 1)) And _
source_range.Offset(0, 1)(target_counter + 1) = target_range.Offset(0, 1)(target_counter + 1) Then
____________________________
End If
Next
Next
End Sub
Thanks for your time and help!
D
Bookmarks