Copy & Paste to the next empy cell. (Vba Code not Working)

  • Hello,



    I created a macro button to copy a cell and paste value in another sheet but it just replaces the value in the same cell on the other sheet. I need it to count the columns and continue to paste the value in the next cell to the right. The code below is what i currently using to make it happen, this worked on prior spreadsheets I have done but not sure what I'm doing wrong. Please Help..



    Code
    Col = Sheet3.Cells(11, 11).CurrentRegion.Columns.Count + 1
    Sheet3.Cells(11, 11) = Sheet2.Range("E10")
  • This line does not do anything to your range to paste the way you have the line after.

    Code
    Col = Sheet3.Cells(11, 11).CurrentRegion.Columns.Count + 1


    This is where you paste it.

    Code
    Sheet3.Cells(11, 11) = Sheet2.Range("E10")


    If all the rows are the same length (filled to the same column):

    Code
    col = Sheet3.Cells.Find("*", , , , xlByColumns, xlPrevious).Column
    Sheet3.Cells(11, col).Offset(, 1) = Sheet2.Range("E10")


    If you only want for row 11

    Code
    col =Sheet3. Cells(11, Columns.Count).End(xlToLeft).Column
    Sheet3.Cells(11, col).Offset(, 1) = Sheet2.Range("E10")


    If you want to stay with what you showed in your post

    Code
    Sheet3.Cells(11, col) = Sheet2.Range("E10")
  • X posted

    vbaexpress.com/forum/showthrea…ell-(Vba-Code-not-Working)



    mrexcel.com/board/threads/copy…code-not-working.1131272/


    Cross-posting Without Telling Us


    Your post does not comply with our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.


    Post a link to any other forums where you have asked the same question.


    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.


    Go to https://www.excelguru.ca/content.php?184 to understand why we ask you to do this.


    Also, you have not used code tags as prescribed in our forum rules. I have added them for you today.


    I have added the crosspost reference for you today. Please comply with this and all our rules in the future

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!