+ Reply to Thread
Results 1 to 4 of 4

Copy/Paste Range with Unknown End Point

Hybrid View

  1. #1
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Copy/Paste Range with Unknown End Point

    Okay, so I have a sheet that I need to be able to copy the information from Columns B through CC and paste them into another workbook in columns A through CB in row 2.

    The first 7 rows are headers, so if there are 5 lines of data, the Range to copy would be B8:CC12. So the only unknown is the number of rows in column CC.

    Can I write a macro that will find the last row of data on the sheet and use the number of that row in the range to copy?

    Any advice would be greatly appreciated.

    Thanks in advance!

    -Amy Kate

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Copy/Paste Range with Unknown End Point

    Can I write a macro that will find the last row of data on the sheet and use the number of that row in the range to copy?
    Something along these lines, adjust sheet reference as required:

    Dim lrow As Long
    
    lrow = Sheet1.Cells(lrow, "CC").End(xlUp).Row
    
    range("B8:CC" & lrow).Copy
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Dorset, UK
    MS-Off Ver
    Office 2003, Office 2007
    Posts
    131

    Re: Copy/Paste Range with Unknown End Point

    Try something like:
    Dim C As Range
    
    Set C = Range("B:CC").SpecialCells(xlLastCell)
    
    'put the rest of your code here
    The in your copy range you want something like Range("B8:CC" & C.Row)

  4. #4
    Forum Contributor amyxkatexx's Avatar
    Join Date
    11-23-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    128

    Re: Copy/Paste Range with Unknown End Point

    Ah, you rock!

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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