+ Reply to Thread
Results 1 to 1 of 1

Change macro to consolidate another row

  1. #1
    Registered User
    Join Date
    10-07-2011
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    13

    Change macro to consolidate another row

    I have this macro-----It will run when i click a button on sheet2

    Sub btn_Consolidate_Click()

    Static wsData As Worksheet: Set wsData = Sheets("Sheet1")
    Static wsDest As Worksheet: Set wsDest = ActiveSheet

    wsDest.UsedRange.Offset(1).ClearContents
    Intersect(wsData.UsedRange, wsData.Columns("A")).AdvancedFilter xlFilterCopy, , wsDest.Range("A1"), True
    With Range(wsDest.Range("B2"), wsDest.Cells(Rows.Count, "A").End(xlUp).Offset(0, 1))
    .Formula = "=SumIf('" & wsData.Name & "'!A:A,A2,'" & wsData.Name & "'!B:B)"
    .Value = .Value
    End With


    End Sub

    It consolidates data from sheet 1 column A (which is ID numbers) and sums the corresponding data from column b and with a click of a button places it on sheet two.
    Two questions....how do I change this macro so that it will sort the results on sheet two by descending in column b?
    Also I want to fill in the same type of data on Column C and D of sheet one and have a command button on sheet two that will do the same thing but on column C and D and then continue on with E and F. Then G and H, I and J, K and L........I need a hundred macro buttons on sheet 2.
    Attached is what I have so far....Thanks
    Attached Files Attached Files

+ Reply to Thread

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