+ Reply to Thread
Results 1 to 5 of 5

Require Last two column Data copy from another sheet

Hybrid View

  1. #1
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Require Last two column Data copy from another sheet

    Hi Friends,

    Please help me for copy entire column as highlighted from sheet2 and paste in sheet1 with end(xl) column function.

    I have done code in file but there is gap in coding.

    Please help me out for this code.

    Regards
    Sandeep Kumar
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Require Last two column Data copy from another sheet

    Hi friends,

    Copy entire last to column from sheet2.

    Regards
    Sandeep Kumar

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,913

    Re: Require Last two column Data copy from another sheet

    Option Explicit
    
    Sub sandeep()
        Dim lr As Long, lc As Long
        Dim s1 As Worksheet, s2 As Worksheet
        Set s1 = Sheets("Sheet1")
        Set s2 = Sheets("Sheet2")
        lr = s2.Range("B" & Rows.Count).End(xlUp).Row
        lc = s2.Cells(5, Columns.Count).End(xlToLeft).Column
        s2.Range(Cells(5, lc - 1), Cells(lr, lc)).Copy
        s1.Range("A1").PasteSpecial xlPasteValues
        Application.CutCopyMode = False
        MsgBox "completed"
    End Sub
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Registered User
    Join Date
    01-27-2020
    Location
    Delhi
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Require Last two column Data copy from another sheet

    Thanks for this.

    Sir I forgot a filed, now entered in sheet.

    For you reference against I am attaching the file.


    Regards
    Sandeep Kumar
    Attached Files Attached Files

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,913

    Re: Require Last two column Data copy from another sheet

    Merged cells do not work in VBA. Unmerge the cells and change this line of code.

    s2.Range(Cells(5, lc - 1), Cells(lr, lc)).Copy
    to

    s2.Range(Cells(3, lc - 1), Cells(lr, lc)).Copy

    Read this thread

    http://www.vbaexpress.com/forum/show...h-merged-cells

    and this one

    https://www.quora.com/Why-are-people...merge-in-excel

+ 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. Replies: 2
    Last Post: 11-13-2019, 11:26 PM
  2. Replies: 1
    Last Post: 02-09-2017, 05:36 AM
  3. Replies: 1
    Last Post: 02-09-2017, 05:30 AM
  4. Require VBA code to Transfer specific data from one sheet to another sheet.
    By xlhelp7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2017, 10:20 AM
  5. Copy data from sheet1 column with dynamic date, and copy data to second sheet column
    By Renaliiii in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2016, 04:44 PM
  6. Copy column data on one sheet to row or column date on another sheet based on user in
    By soready42012 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-08-2012, 12:03 AM
  7. Replies: 1
    Last Post: 03-02-2010, 01:23 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