+ Reply to Thread
Results 1 to 2 of 2

aggregating two columns into one

Hybrid View

missy22 aggregating two columns into... 08-28-2015, 06:43 AM
JOHN H. DAVIS Re: aggregating two columns... 08-28-2015, 07:35 AM
  1. #1
    Forum Contributor
    Join Date
    08-08-2012
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    196

    aggregating two columns into one

    I am writing to seek help in creating a macro functionality which allows you to copy two different columns from one sheet to another sheet into one column.
    I manage to find a macro with a similar functionality but I keep getting a run-time error on the macro code below.


    Sample file:

    Please see the attachment for further details.
    column_aggregation.xls

    Expected output
    Column B & C from Sheet1 copied & aggregated into column M under sheet called = output.

    Code:
    Sub copy2Columns()
    
    Dim lRow As Long
    lRow = Sheets("Output").Range("M" & Rows.Count).End(xlUp)(2).Row
    'If lRow < 5 Then lRow = 5
    Range("B2:B").Copy Destination:=Sheets("Output").Range("M" & lRow)
    Range("C2:C").Copy Destination:=Sheets("Output").Range("M" & Rows.Count).End(xlUp)(2)
    End Sub
    Any further assistance would be very much appreciated. Many thanks for your time and feedback.
    Last edited by missy22; 08-28-2015 at 07:11 AM.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: aggregating two columns into one

    Maybe:

    Sub missy22z()
    Dim i As Long
    For i = 2 To Range("B" & Rows.Count).End(3).row
        If Cells(i, "B") <> "" Then
        Sheets("Output").Range("M" & i) = Cells(i, "B") & " " & Cells(i, "C")
        End If
    Next i
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Aggregating data
    By brianknie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2013, 01:18 PM
  2. aggregating numbers based on dates/ row columns
    By holycowbanana85 in forum Excel General
    Replies: 4
    Last Post: 07-23-2012, 03:13 PM
  3. Aggregating by time
    By andykent99 in forum Excel General
    Replies: 2
    Last Post: 01-21-2012, 08:41 PM
  4. Aggregating Cases
    By Toby2010 in forum Excel General
    Replies: 9
    Last Post: 01-27-2011, 04:34 PM
  5. Need help aggregating data
    By glazedfaith in forum Excel General
    Replies: 6
    Last Post: 11-30-2010, 01:29 PM
  6. Aggregating data without a pivot?
    By adr150 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-22-2008, 03:39 PM
  7. Aggregating data
    By pilotdata in forum Excel General
    Replies: 6
    Last Post: 11-09-2005, 10:35 AM
  8. [SOLVED] Aggregating data
    By JVLin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-08-2005, 12:06 PM

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