+ Reply to Thread
Results 1 to 6 of 6

Copy & paste in macro doesn't paste all cells

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Copy & paste in macro doesn't paste all cells

    I created a macro using the recording function. I don't know VBA, so I'm not real sure how to resolve some of the issues. In this macro, I was trying to copy a range of 7 columns (92 rows) of data, of which only 5 columns contain data, and paste them into another worksheet. Depending on the data set, there could be data in 5, 6 or 7 columns. When I re-ran the macro with 7 columns of data, only 5 of the columns are getting pasted. I initially recorded the macro with no data, and no matter if I have 5, 6 or 7 columns of data, I only get 5 of the columns in my receiving worksheet. What should I look for in the code to fix this so that no matter what I paste in 7 columes?

    Here's the code:

    Please Login or Register  to view this content.
    Thanks!
    Last edited by alansidman; 10-13-2013 at 01:18 AM. Reason: code tags added

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Copy & paste in macro doesn't paste all cells

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (I added them this time. Please read the rules and abide by them in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Copy & paste in macro doesn't paste all cells

    Thanks...first time I asked for help on code.

    Do you know how I can fix the error? Well, not actually "error", just doesn't deliver full data.

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Copy & paste in macro doesn't paste all cells

    Where are you pasting the copied cells to?
    Perhaps, uploading your spreadsheet with the macro in place so that we can analyze the whole picture.

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Copy & paste in macro doesn't paste all cells

    File is attached. I appreciate the help. I don't even get any data to paste now. Am using the data set on the last tab.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy & paste in macro doesn't paste all cells

    The code is working as it is copying 7 columns G-M. I have just added the sheet names to avoid using active sheet, but I have not looked at the rest of the code(Only the first 5 lines).
    You can adjust the number of columns you want to copy by changing this line. This line copies G10-M columns until the last data. If you want to reduce to 5, change the M in to K

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Replies: 1
    Last Post: 01-16-2013, 05:36 AM
  2. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  3. Copy and paste non consecutive cells and paste consecutively in another workbook
    By macquhele in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2011, 02:36 PM
  4. 2 Macro's: only vertical copy/paste action and copy-paste 14 columns to the right.
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2010, 10:34 AM
  5. Copy and Paste macro needs to paste to a changing cell reference
    By loulou in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-24-2005, 07:06 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