+ Reply to Thread
Results 1 to 12 of 12

Copy paste entire row different sheet column C

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Copy paste entire row different sheet column C

    I am trying to copy and paste to a different sheet, and need to paste the rows starting in column C rather than Column A.

    THe VBA is for a Copy Unique rows. Works great but need to post in Column C of "Check List" rather than Column A. Don't need to copy the entire row, just out to Column BB. New to VBA.

    Option Explicit
    Sub CopyAndRemoveDups()
    Dim cl As Range
    Dim ws As Worksheet
    Dim x As Long
    Dim LastRow As Long
    Dim rng As Range
    Dim rngToDelete As Range


    Set ws = Worksheets("query")
    With ws

    For Each cl In .Range("A1:A" & .Range("A65536").End(xlUp).Row)
    If cl.Value <> "" Then
    cl.EntireRow.Copy Worksheets("Check List").Range("A65536").End(xlUp).Offset(1, 0)
    End If
    Next cl
    End With

    Set ws = Worksheets("Check List")
    'Advanced Filter requires a header row- let's add a temporary one
    ws.Rows(1).Insert
    ws.Cells(1, 1).Value = "temp header"
    'Set Filter column
    Set rng = ws.Range("D1:D10000")
    rng.AdvancedFilter xlFilterInPlace, Unique:=True
    Set rngToDelete = rng.SpecialCells(xlCellTypeVisible)
    ws.ShowAllData
    rngToDelete.EntireRow.Hidden = True
    rng.SpecialCells(xlCellTypeVisible).EntireRow.Delete
    rngToDelete.EntireRow.Hidden = False

    'remove the temporary row
    ws.Rows(1).Delete


    End Sub


    Thank you for your help

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Copy paste entire row different sheet column C

    You need to use Code Tags in your post.

    You cannot copy an entire row & start in C, the sizes will not match
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-14-2011
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    64

    Re: Copy paste entire row different sheet column C

    Do I read right, if I understand it as if you want to copy the row from A to BB in sheet "query" if there's any value in the cell in column A?
    The paste in into sheet "Check List" from column C to BD?

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy paste entire row different sheet column C

    Maybe change your loop to this?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Copy paste entire row different sheet column C

    Quote Originally Posted by royUK View Post
    You need to use Code Tags in your post.

    You cannot copy an entire row & start in C, the sizes will not match

    Can you give me more info on that? New to VBA. Do I need to use a range instead of cl.entirerow? Code? Thank you for your help.

  6. #6
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Copy paste entire row different sheet column C

    Pasted the code in place of mine and now it only pastes the last row of the data, but it is going into column C. Further ideas?

  7. #7
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Copy paste entire row different sheet column C

    the current code will paste the rows of data in column A on the "check List". I need it the rows to start in column C instead of A on "Check List". I understand that I can't paste an entire row on "Check List" starting in column C, but don't know how to shorten the range from entirerow.

    Thank you

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy paste entire row different sheet column C

    Did you try the suggestion in Post 4?

  9. #9
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Copy paste entire row different sheet column C

    Pasted the code in place of mine and now it only pastes the last row of the data, but it is going into column C.

  10. #10
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy paste entire row different sheet column C

    Based on reading this thread. I thought you wanted it to go into Column C? Is that correct?

  11. #11
    Registered User
    Join Date
    06-14-2012
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Copy paste entire row different sheet column C

    Yes I want it to paste the row starting in column c on "check list". But there are multiple columns, and the number of rows will vary. And the new code is only copying the last row.

  12. #12
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy paste entire row different sheet column C

    The only difference in the new code and the old code is that 1) It changes the range to copy from EntireRow to the Columns, specified and 2) It changes the destination from Column A to Column C using the offset function. If the original code worked, then I can't see why those revisions would have changed the result? Can you attach a sample of your workbook?

+ Reply to Thread

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