Results 1 to 6 of 6

Copying specific cells from one worksheet to another

Threaded View

  1. #1
    Registered User
    Join Date
    08-04-2011
    Location
    Toronto
    MS-Off Ver
    Excel 2007
    Posts
    8

    Question Copying specific cells from one worksheet to another

    Hi,

    I'm hoping someone can help. I have created a workbook with two sheets. A sheet named "Invoice" and another named "Sales Summary Sheet" (SSS).

    After clicking on a button (on the Invoice sheet), data in specific cells get copied to specific cells in SSS.

    I want to copy row(s) depending on how many rows are entered into the Invoice template, to the SSS sheet. Currently rows A19:H19, A20:H20, A21:H21...to A32:H32 are rows that can have potential data in it that need to be copied to rows in the SSS sheet.

    For every row in the Invoice sheet, I need to copy the data to a new row in the SSS sheet (and not overwrite existing rows of data in the SSS sheet). So for example row A19:A32 need to be copied to A2:O2, and if data in B19:B32 exists , then it also needs to be copied to A3:O3.

    Once SSS is saved, the next time I open Invoice and re-enter data into A19:A32, it will add the data into SSS in cells A4:O4.

    Right now I have this current code:

    Private Sub CopyToSheet_Click()
    Dim LastRow As Object
    Set LastRow = Sheet1.Range("A19:H32").End(xlUp)
    
    'Range("A19:H32").Copy Destination:=Sheets("Sheet1").
    'Adds the data to Sales Summary Sheet
    'Sheet1 is the (Name) of the sheet, i.e. the object
    'NOT the name in the tab of the sheet
    LastRow.Offset(1, 0).Value = Sheet4.Range("H8").Value
    LastRow.Offset(1, 1).Value = Sheet4.Range("H7").Value
    LastRow.Offset(1, 2).Value = Sheet4.Range("B19:B32").Value
    LastRow.Offset(1, 3).Value = Sheet4.Range("A19:A32").Value
    LastRow.Offset(1, 4).Value = Sheet4.Range("A6").Value
    LastRow.Offset(1, 5).Value = Sheet4.Range("F19:F32").Value
    LastRow.Offset(1, 6).Value = Sheet4.Range("H19:H32").Value
    LastRow.Offset(1, 7).Value = Sheet4.Range("H12").Value
    End Sub

    When I run the above code, it only copies row A19:H19 in the Invoice sheet to row A2:O2 in SSS, and DOES NOT copy the second (third, fourth...) row of data to SSS.

    Please see attachments to see what the Invoice (before) and SSS sheet (after) should look like.

    Any help would be GREATLY APPRECIATED!

    Thanks
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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