Results 1 to 5 of 5

Combine Equal rows (columns C & G) and Sum (columns E & F)

Threaded View

  1. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Combine Equal rows (columns C & G) and Sum (columns E & F)

    hi rxk. it would be good to upload an excel sample so that we don't have to manually key on our own to test. i have filled up just the essential information and you may try this:
    Sub test()
    
    Cells(1, 1).CurrentRegion.Sort key1:=Cells(1, "C"), order1:=xlAscending, key2:=Cells(1, "G"), order2:=xlAscending, Header:=xlYes
    
    LR = Cells(Rows.Count, 1).End(xlUp).Row
    For RowX = LR To 2 Step -1
        If Cells(RowX, "C") = Cells(RowX - 1, "C") And Cells(RowX, "G") = Cells(RowX - 1, "G") Then
            If Cells(RowX, "F") <> vbNullString Then
                Cells(RowX - 1, "F") = Cells(RowX - 1, "F") + Cells(RowX, "F")
            Else
                Cells(RowX - 1, "E") = Cells(RowX - 1, "E") + Cells(RowX, "E")
            End If
            Rows(RowX).Delete
        End If
    Next
    
    End Sub
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. If columns are equal, combine rows and sum cells ?
    By katievh in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-11-2017, 01:03 PM
  2. [SOLVED] combine many columns data into half columns data by creating rows
    By killerware in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2013, 07:53 AM
  3. Duplicate rows, delete columns w/same data, combine columns w/unique data, Mac Excel 2011
    By msmcoin in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 2
    Last Post: 02-03-2013, 02:10 PM
  4. Creating equal rows and columns
    By ElTurbo in forum Excel General
    Replies: 11
    Last Post: 07-11-2011, 04:35 PM
  5. Need help transposing Rows into 3 equal columns
    By Onenguyen in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-06-2010, 10:52 AM
  6. Replies: 2
    Last Post: 01-14-2009, 04:01 AM
  7. [SOLVED] Combine multiple columns into two long columns, Repeating rows in first column
    By anasab@gmail.com in forum Excel General
    Replies: 0
    Last Post: 07-31-2006, 12:13 PM

Tags for this Thread

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