+ Reply to Thread
Results 1 to 7 of 7

Macro that copy and pastes last used row under last used row

  1. #1
    Registered User
    Join Date
    10-31-2017
    Location
    Seattle
    MS-Off Ver
    2016
    Posts
    3

    Macro that copy and pastes last used row under last used row

    This is my macro so far. It copies and pastes the last used row under the last used row. I just want it to copy and paste A-I which messes up when I try to input it.
    Please Login or Register  to view this content.


    Thanks
    Last edited by alansidman; 11-02-2017 at 12:25 AM.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Macro that copy and pastes last used row under last used row

    Hi paytoplay, welcome! This procedure finds the last used cell in column A, copies columns A:I of that row, and pastes them on the next row down.:
    Please Login or Register  to view this content.
    Last edited by leelnich; 11-01-2017 at 07:46 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  3. #3
    Registered User
    Join Date
    10-31-2017
    Location
    Seattle
    MS-Off Ver
    2016
    Posts
    3

    Re: Macro that copy and pastes last used row under last used row

    awesome, this worked great. Sorry but could you run through a little bit of what each code does so I know how to tackle it next time? I'm relatively new to VBA, but it's very fun and frustrating

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Macro that copy and pastes last used row under last used row

    Please Login or Register  to view this content.
    'All defined cell ranges are assumed to be on the ACTIVE worksheet unless
    'some other sheet is specified, so let's activate the one we're working on.

    Please Login or Register  to view this content.
    'Starting at the very bottom of column A, search up until you find a NON-BLANK cell.
    'This is equivalent to selecting cell A10488576 and pressing CTRL + UP_ARROW.
    'Once you've got the right single-cell range, expand it to include 1 row x 9 columns.

    'The With statement lets us temporarily use methods and properties on a specified OBJECT
    ' - in this case our 9-cell range - without having to fully "qualify" it every time. Simply
    'precede the method or property with a period ("."); VBA will know which object they apply to.

    Please Login or Register  to view this content.
    'We're applying the Range.Copy and Range.Offset methods to the last row of data. The Range.Copy
    'method has an option to do "simple" copy/pastes in one operation by specifying the destination.
    '(If you need more control over the process, use a separate Range.PasteSpecial statement.) We
    'want to paste in the next row down. The Range.Offset method is perfect for this; it let's us
    'designate row- and column-offsets to define a new range of the same size as this one.

    Please Login or Register  to view this content.
    'We're done working with this object, so terminate the With "block". With statements can make
    'your code shorter AND faster, but tread carefully. A missing period is difficult to spot, but
    'can cause your procedures to crash or behave strangely. Many a bug has been born thusly.

    Please Login or Register  to view this content.
    'Turn off the "Marching Ants" (animated copy border) and return to standard ready mode.

    Please Login or Register  to view this content.

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

    Re: Macro that copy and pastes last used row under last used row

    @paytoplay

    Code Tags Added
    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 at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply 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

  6. #6
    Registered User
    Join Date
    10-31-2017
    Location
    Seattle
    MS-Off Ver
    2016
    Posts
    3

    Re: Macro that copy and pastes last used row under last used row

    @leelnich thank you so much. one day I will eventually be as good with VBA and teaching as you are

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Macro that copy and pastes last used row under last used row

    You're welcome, thank you for the rep! When it comes to coding, it's all about moving in a known direction through trial and error. Don't be afraid to fail, and don't hesitate to ask for help when you're truly stuck.
    Last edited by leelnich; 11-02-2017 at 03:19 PM.

+ 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. I want a macro that copy and pastes
    By Waffels in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2017, 06:00 PM
  2. [SOLVED] Macro that Copy and Pastes next to a certain value
    By Nuccio92 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2016, 07:26 PM
  3. Replies: 1
    Last Post: 10-03-2012, 07:06 PM
  4. Replies: 2
    Last Post: 09-05-2012, 03:20 PM
  5. A macro that copy and pastes to line below
    By streyb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 08:00 PM
  6. [SOLVED] Automating a macro that copies and pastes data and pastes 2 rows under the previous one.
    By thebank in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2012, 05:02 PM
  7. Two copy and pastes in a macro
    By nygwnj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-09-2007, 05:17 PM

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