+ Reply to Thread
Results 1 to 5 of 5

VBA copy/paste pasting to wrong row

  1. #1
    Registered User
    Join Date
    07-31-2014
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    49

    Question VBA copy/paste pasting to wrong row

    Let me start by saying that I am one of those who's best friend is Google when trying to cobble vba code together for a spreadsheet. I had the following code working, then broke it. All it is supposed to do is clear the contents of cells in AL6 to AQ & Lastrow. Copy values from several columns (A6 to C & lastrow, G6 to I & lastrow, M6 to O & lastrow, etc) and stack that data in AL6 to AN & lastrow. Then copy values from another similar set of columns and stack that data in AO6 to AQ & lastrow.

    The code worked as expected, until I started messing around with code to get columns sorted. It started pasting starting in AL2 instead of AL6 and AO2 instead of AO6 as expected. I deleted the sort code. I went into the spreadsheet and manually cleared any sorting that I could find, but still pasting everything starting in row 2 instead of 6. What did I do?

    Here's my code in all it's glory. May not be pretty to some here in the forum, but it used to work, at least. Any help appreciated.

    Please Login or Register  to view this content.
    Last edited by LITOA; 11-25-2016 at 05:31 PM.

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: VBA copy/paste pasting to wrong row

    Could you upload sample file with sample data?

  3. #3
    Registered User
    Join Date
    07-31-2014
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    49

    Re: VBA copy/paste pasting to wrong row

    Absolutely. Give me a moment to do some trimming.

  4. #4
    Registered User
    Join Date
    07-31-2014
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    49

    Re: VBA copy/paste pasting to wrong row

    Here is a sample of the problem. I have a temporary button in cell AP1 to trigger the code.

    Edit: Well, apparently there is no way to remove one attachement, and replace it with another thru the edit function. Oh, well. Both are the same, only the names have been changed to protect the innocent.
    Attached Files Attached Files
    Last edited by LITOA; 11-25-2016 at 06:11 PM.

  5. #5
    Registered User
    Join Date
    07-31-2014
    Location
    Texas
    MS-Off Ver
    Microsoft Office Professional Plus 2021
    Posts
    49

    Re: VBA copy/paste pasting to wrong row

    Thanks anyway. By going thru the logical steps of the code, I figured out that by clearing the contents of the cells in the first step, the code that I expected to paste below my 6 row header by testing for contents of a cell and then offsetting 1 row down was pasting on row 2 because my header had been cleared in the first step. Thanks to all that looked into this.

+ 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. [SOLVED] It sets date format wrong when copy and paste
    By zanshin777 in forum Excel General
    Replies: 18
    Last Post: 01-16-2016, 08:16 AM
  2. Copy/Paste restriction removed when pasting from one wb to another
    By iecbso in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2015, 01:13 PM
  3. Copy and paste under the last used row - what's wrong with this code?
    By luke1908 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 04:10 PM
  4. Copy and paste code pasting won't paste just values
    By thehotbreadguy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2013, 11:12 PM
  5. [SOLVED] Copy/paste button code work wrong
    By mirenoba in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-05-2013, 05:52 AM
  6. Copy/paste-button - wrong reference code in sheet 2
    By Krapter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-08-2009, 05:17 AM
  7. Copy-paste from csv to xls macro > wrong date format
    By Gero in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2009, 06:12 AM

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