Combine columns in excel

[Solved/Closed]
Report
-
 Carman -
Hello,
i have got two sheets of data and i have arranged them into ideal orders. Now i want to place data on sheet 2 behind data on sheet 1.( in the same region/column)I need a VBA code to perform the job as further update is needed.

please take a look at the reference file:
https://authentification.site/files/23432694/Book1.xls

Sheet 3 is the output form that i want but i would like it to be in sheet 1 when the job is done.

Thanks

2 replies


Dear Carman,

Please get through the following Kioskea FAQ article in order to get the task completed.

https://ccm.net/faq/

Thank you.
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
Try this
This is based on assumption that columns in both sheets are in same order and at same location

Try this

Sub CopyData()
Dim lSrcMaxRows As Long
Dim lTgtLastRow
Dim Cell As Range

Dim sTgtSht As String
Dim sSrcSht As String

    sSrcSht = "Sheet2"
    sTgtSht = "Sheet1"
    
    Sheets(sSrcSht).AutoFilterMode = False
    
    Set Cell = Sheets(sSrcSht).Cells.Find("*", Cells(1, 1), SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
    If Cell Is Nothing Then Exit Sub
    lSrcMaxRows = Cell.Row
    
    Sheets(sTgtSht).AutoFilterMode = False
    
    Set Cell = Sheets(sTgtSht).Cells.Find("*", Cells(1, 1), SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
    
    If Cell Is Nothing Then
        lTgtLastRow = 0
    Else
        lTgtLastRow = Cell.Row
    End If
    
    lTgtLastRow = lTgtLastRow + 1
    
    Application.CutCopyMode = False
    
    Sheets(sSrcSht).Select
    If (lTgtLastRow = 1) Then
        Rows("1:" & lSrcMaxRows).Copy
    Else
        Rows("2:" & lSrcMaxRows).Copy
    End If
    
    Sheets(sTgtSht).Select
    Cells(lTgtLastRow, "A").PasteSpecial
    Application.CutCopyMode = False
    Set Cell = Nothing

End Sub
Your code works perfectly well!!
Thank you very very much!!