Results 1 to 5 of 5

Merging data

Threaded View

sessy Merging data 09-09-2009, 07:16 PM
martindwilson Re: Merging data 09-09-2009, 07:44 PM
shg Re: Merging data 09-09-2009, 07:50 PM
sessy Re: Merging data 09-09-2009, 08:11 PM
StephenR Re: Merging data 09-10-2009, 05:15 AM
  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    5

    Merging data

    Hi,

    I'm trying to search a list for names and add totaled data for new names to another list. However, I end up adding a new row for each time I find a name that doesn't match because if the name doesn't match a row it gets added, then it checks the next row for a match and will add it again if it's not the same. I know what the problem is, but I don't know how to fix it! Any help would be appreciated.

    NAdvisors is the number of rows already in the list I'm creating.
    NRows is the rows in the list I'm adding data from.

    
    With Worksheets("Reps_Capsil_Sales").Range("E1")
        For j = 1 To NRows
            NewRows = 0
            If .Offset(j, 1) = Consultant Then
                For i = 1 To NAdvisors
                    Counter = 0
                    
                    ' Find advisors who aren't on the Activity vs Sales Spreadsheet
                    If .Offset(j, 0) <> LastName(i) & ", " & FirstName(i) Then
                        NewRows = NewRows + 1
                        IMAdvisor = .Offset(j, 0).Value
                            If IsNumeric(.Offset(j, 17).Value) Then
                            Counter = Counter + .Offset(j, 17).Value
                            IMAdvisorPurch = Counter
                            End If
                    End If
                Next
                
                ' Add these advisors to the new list
                With Worksheets(Consultant).Range("A1")
                    NewRows = Range(.Offset(1, 0), .End(xlDown)).Rows.Count
                    .Offset(NewRows + 1, 0).Value = IMAdvisor
                    .Offset(NewRows + 1, 1).Value = "0"
                    .Offset(NewRows + 1, 2).Value = "0"
                    .Offset(NewRows + 1, 3).Value = "0"
                    .Offset(NewRows + 1, 4).Value = "$0.00"
                    .Offset(NewRows + 1, 5).Value = IMAdvisorPurch
                    '  Fit columns to cell contents
                    .Offset(0, 0).EntireColumn.AutoFit
                    .Offset(0, 1).EntireColumn.AutoFit
                    .Offset(0, 2).EntireColumn.AutoFit
                    .Offset(0, 3).EntireColumn.AutoFit
                    .Offset(0, 4).EntireColumn.AutoFit
                    .Offset(0, 5).EntireColumn.AutoFit
                End With
            End If
        Next
    End With
    Last edited by sessy; 09-09-2009 at 08:02 PM.

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