Results 1 to 3 of 3

Sum multiple nested loop entries

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2009
    Location
    O.o
    MS-Off Ver
    Excel 2003
    Posts
    64

    Sum multiple nested loop entries

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1