+ Reply to Thread
Results 1 to 5 of 5

Copy cell values from one sheet and paste it in another sheet of the same workbook

  1. #1
    Registered User
    Join Date
    03-07-2016
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2007, 2013
    Posts
    11

    Copy cell values from one sheet and paste it in another sheet of the same workbook

    Hello

    Please find the excel file attached below. I have assigned a macro in "Save" button in Sheet1. How can I copy cells one by one from sheet1 and paste it in Sheet2. Sheet2 will have the values in same order as in Sheet1.

    Regards
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Copy cell values from one sheet and paste it in another sheet of the same workbook

    Maybe the below is what you want!

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-07-2016
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2007, 2013
    Posts
    11

    Re: Copy cell values from one sheet and paste it in another sheet of the same workbook

    Thank you so much for your quick response. But, While debugging I came across "Run-time error '1004'." Method 'Range' of object '_Worksheet' failed. How to overcome it.

  4. #4
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Copy cell values from one sheet and paste it in another sheet of the same workbook

    Runs fine in the attached worksheet. Make sure that there is data in some rows on Sheet 1. Use break and the immediate window to check that the rows are correct.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-07-2016
    Location
    Dhaka, Bangladesh
    MS-Off Ver
    2007, 2013
    Posts
    11

    Re: Copy cell values from one sheet and paste it in another sheet of the same workbook

    Thanks once again. But after spending lot of time, I managed to come up with the job I want my macro to do it for me. Therefore, I am sharing it with all the members of the forum. Here is the code....... I would also love to hear it from you EssoExplJoe.

    Private Sub CommandButton1_Click()
    Dim lastcol As Long, lastrow As Long, lastrow2 As Long, ecol As Long, i As Integer, x As Integer

    lastcol = Sheet1.Cells(1, Columns.Count).End(xlToLeft).Column
    lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
    lastrow2 = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row + 1

    For x = 2 To lastrow
    For i = 1 To lastcol
    Sheet1.Cells(x, i).Copy
    ecol = Sheet2.Cells(x, i).End(xlUp).Offset(1, 0).Column
    Sheet1.Paste Destination:=Sheet2.Cells(lastrow2, ecol)
    Next i
    lastrow2 = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    Next x


    Application.CutCopyMode = False
    Sheet1.Select
    Sheet1.Rows("2:" & Rows.Count).ClearContents

    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. Copy values from sheets in workbook and paste in one sheet in the same workbook
    By RinorM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2015, 04:14 AM
  2. Replies: 3
    Last Post: 11-06-2014, 01:23 AM
  3. Copy & Paste Cell Data to Another Sheet in Workbook
    By nva2k4 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-10-2014, 07:00 PM
  4. VB Script to copy particular cell values and paste in new sheet?
    By WL2005HBD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-20-2013, 10:39 PM
  5. [SOLVED] should copy and paste the intersect values from sheet 1 to sheet 2
    By Apps in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-12-2013, 10:06 AM
  6. Copy rows until a empty cell and paste them into a new sheet or workbook
    By nkf531 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-05-2012, 06:27 AM
  7. Find value from sheet 1, cell A1 in sheet(s) 2 (3, 4?), copy, paste row to sheet 8
    By fleeting in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2011, 03:31 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