+ Reply to Thread
Results 1 to 5 of 5

Macro Recording: Copy Ranges

Hybrid View

  1. #1
    Forum Contributor wedzmer's Avatar
    Join Date
    06-13-2014
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    422

    Macro Recording: Copy Ranges

    I tried to use macro recording and after I viewed the codes, I didn't think anything was wrong.
    The goal I wanted was that to keep the selection of the selected cells/ranges to be copied in excel clipboard. The code looked like this:

    Sub Copy_Scores()
    '
    ' Copy_Scores Macro
    ' CopyScores in Clipboard
    '
    
    '
        Range("M11:V11,Z11:AI11,AM11,M13:V27,Z13:AI27,AM13:AM27").Copy
        Range("am13").Activate
        
    End Sub
    The code, as you can see wishes to exclude the columns W, X, Y, AJ, AK, and AL. Also, I don't wish to select everything that is found in Row 12.

    However, when I tried to paste in on any other sheet, it contains all the columns and rows which where in selected all within M11:AM27.

    PS

    I do not wish to put a paste function in the macro since I'm really not sure where or what particular file or sheet I would be pasting the said data.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,802

    Re: Macro Recording: Copy Ranges

    Quote Originally Posted by wedzmer View Post
    ...when I tried to paste in on any other sheet, it contains all the columns and rows which where in selected all within M11:AM27.
    You get exactly the same behavior as if you selected those cells, copied, and then pasted. You might want to try that and see how it works.

    It includes exactly what you specify. However, when you paste, the shape is not preserved. That is, the data is pasted into a solid block instead of skipping columns that correspond to the columns skipped in the copy operation.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor wedzmer's Avatar
    Join Date
    06-13-2014
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    422

    Re: Macro Recording: Copy Ranges

    Quote Originally Posted by 6StringJazzer View Post
    You get exactly the same behavior as if you selected those cells, copied, and then pasted. You might want to try that and see how it works.

    It includes exactly what you specify. However, when you paste, the shape is not preserved. That is, the data is pasted into a solid block instead of skipping columns that correspond to the columns skipped in the copy operation.
    Oh man! I just did that and you were right.. damn!

    Do i have any other choice here? I mean is there any way I would be able to do what I wanted to happen?

    Suggestions please..

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,802

    Re: Macro Recording: Copy Ranges

    Hard to say without knowing your whole data layout and what you are trying to do. What is in cells in the range M11:AM27 that are not included in the copy range? What is in the corresponding cells in the destination range?

    Because you are not controlling the paste operation from your code, it is difficult (or maybe impossible). You could copy the entire range as a single block to the clipboard, but I don't know if that will then include other cells that you don't want, or overwrite cells on the paste operation that you want to preserve.

  5. #5
    Forum Contributor wedzmer's Avatar
    Join Date
    06-13-2014
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    422

    Re: Macro Recording: Copy Ranges

    Quote Originally Posted by 6StringJazzer View Post
    Hard to say without knowing your whole data layout and what you are trying to do. What is in cells in the range M11:AM27 that are not included in the copy range? What is in the corresponding cells in the destination range?
    the cells which are not included in the range are actually two types.. the first one is that Row 12 is actually a spacer between two categories.. since Row 11 is the header which includes different names that vary depending on the user input. the other rows which i wish to exclude is the tally of all the values that are found among the tables. example, M13:V27 are numbers which needed to be analyzed by the columns W, X and Y.

+ 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] How to copy and paste Macro with different ranges?
    By SMIengineering in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2015, 01:55 PM
  2. Macro to copy paste specific charts and ranges to PPT
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-02-2014, 06:07 AM
  3. Record Macro to Copy / Paste Dynamic Ranges
    By Steve N. in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-12-2013, 08:36 PM
  4. [SOLVED] problem in macro recording copy and paste in new excel file,
    By vengatvj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-07-2013, 12:37 AM
  5. Recording a macro to copy from an Input Form
    By TCS111 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-23-2013, 05:12 AM
  6. [SOLVED] Macro to copy and paste Ranges
    By djmarsh51 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-14-2012, 01:58 PM
  7. [SOLVED] Recording macro to copy the data from one worksheet to another worksheet
    By pyol17 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-06-2012, 12:05 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