+ Reply to Thread
Results 1 to 4 of 4

Copy & Paste variable length row using VBA

  1. #1
    Registered User
    Join Date
    11-17-2017
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    60

    Copy & Paste variable length row using VBA

    Hi All,

    I am trying to copy a row "T5" to the end - in this case the row finishes at column "CN" and then paste it into row 3 "T3"

    This is what I have so far, I'm not sure how get it to work.

    Any help is appreciated.

    Thanks
    Nat

    #Sub CopyVariableData()

    Dim LastCol As Integer

    'Find last Column
    LastCol = Cells(5, Columns.Count).End(xlToLeft).Column

    'This hardcode works
    Range("T5:CN5").Copy Destination:=Range("T3")

    'Trying to use the "LastCol" to make it variable(NOT WORKING error)
    Range("T5", Cells(LastCol, "3")).Copy Destination:=Range("T3")

    'This doesn't work either
    Range("T5" & LastCol).Copy Destination:=Range("t3")

    End Sub#
    Last edited by NatalieW12; 02-01-2019 at 09:44 PM. Reason: Trying to add code tags

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Copy & Paste variable length row using VBA

    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-17-2017
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    60

    Re: Copy & Paste variable length row using VBA

    Thank you very Akuini, this works a treat.

    Thank
    Nat

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Copy & Paste variable length row using VBA

    You're welcome, glad to help, & thanks for the feedback.

+ 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] Copy & Paste Variable data length into summary sheet after last used row
    By spyac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-14-2018, 11:31 AM
  2. [SOLVED] Copy variable length column, except for last entry
    By potga in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-29-2016, 07:10 AM
  3. [SOLVED] Copy and Paste a Variable-Length Range
    By andrewc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2015, 12:46 PM
  4. [SOLVED] copy range with variable length
    By Coleman34 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2014, 01:07 PM
  5. Copy formula - for a variable-length list
    By luis33 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-13-2010, 07:58 PM
  6. [SOLVED] Find/Copy Variable length range
    By jnewto@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2006, 03:55 PM
  7. copy variable length cells to a new sheets
    By Souris in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2005, 01: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