Results 1 to 2 of 2

Thread: Error if only one row to copy and paste to another sheet VBA
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    May 2019
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Error if only one row to copy and paste to another sheet VBA

    Hi,
    I have a VBA here that would copy data from one sheet and paste it to the next empty row in another sheet. However, i keep getting error message if there's only 1 row to be copied and pasted to the sheet. Here is my code:
    Sheets("Bryan").Select
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy

    Sheets("Q4").Select
    Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    ActiveWindow.ScrollColumn = 1
    Range("A53").Select
    ActiveSheet.Paste
    Range("H63").Select


    Error:
    Run-time error 1004
    the information cannot be pasted because the copy area and the paste area are not the same size and shape

  2. #2
    Board Regular MARK858's Avatar
    Join Date
    Nov 2010
    Location
    Southern England
    Posts
    11,230
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Error if only one row to copy and paste to another sheet VBA

    Does the below do what you want?

    Code:
    Sheets("Bryan").Range("A2").CurrentRegion.Copy
    Sheets("Q4").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
    Test VBA on a copy of your data (remember you can't normally reverse the action)

    Please follow the forum Rules and Guidelines & please use Code tags around your code i.e. [CODE]your code[/CODE]

    To post a screenshot try one of these links
    MrExcel HTML Maker, RoryA addin (Win & Mac) or Borders-Copy-Paste

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •