Results 1 to 3 of 3

copying data from one sheet to another in different columns

Threaded View

  1. #1
    Registered User
    Join Date
    12-21-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    21

    copying data from one sheet to another in different columns

    Hi Guys

    I am new to VBA trying to create a macro to copy some data from sheet2 (we can have any number of rows in this data it’s not fixed) and paste it to sheet1. Attached is sample data file. I need to copy data from sheet 2 to sheet1.

    Data from column A to C (sheet2) needs to go to first empty cells in column C to E (sheet 1)
    Data from column G to N (sheet2) needs to go to first empty cells in column I to P (sheet 1)
    Data from column AC (sheet2) needs to go to first empty cells in column A E (sheet 1)
    And then in (A, B & Q to AD) columns copy and paste the formula from above cells.

    Just to explain a little more data in sheet2 didn’t had any blank columns actually I inserted these blank columns to match it with sheet1 I thought that might help in copy paste using below code but it isn’t working, any help would be much appreciated:

    Sub copydata()
    Dim lr, lc
    lr = Sheets("sheet2").Cells(Rows.Count, 29).End(xlUp).Row
    lc = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
    Sheets("sheet2").Range("A2:AC" & lr).Copy Destination:=Sheets("sheet1").Cells(lc, 3)
    End Sub
    Attached Files Attached Files

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