+ Reply to Thread
Results 1 to 3 of 3

should this code be on different lines

  1. #1
    Forum Contributor
    Join Date
    08-14-2013
    Location
    LA Baby!!
    MS-Off Ver
    Excel 2007
    Posts
    1,598

    should this code be on different lines

    Should this code be on different lines? I'm using code from someone and it doesn't make sense to me. It's taking used range from one sheet and copying it, right? Doesn't there need to be a paste in the workbooks? It seems like workbooks should be on a different line. Also, what does the last part do with end (3) (2)?

    .Sheets(i).UsedRange.Copy Workbooks("Master workbook.xlsx").Sheets("Master").Range("A" & Rows.Count).End(3)(2)

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: should this code be on different lines

    Hello ammartino44,

    The period before Sheets indicates this code line is part of a With ... End Statement. Please show the full code when posting. Guessing is a waste of time.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: should this code be on different lines

    The way copy syntax works in VBA is you specify what you want to copy then immediately follow it with where you want to copy it to. If you don't specify where to copy it to, it just goes into the clipboard.

    Range("A" & Rows.Count).End(3)(2)

    This code goes to the very last cell in column A all the way at the bottom of the sheet and then comes back up until it runs into some data and then goes down one cell. It finds the very last cell with data in it and goes to the cell below it. This is where what you copied is getting pasted.
    Last edited by skywriter; 04-27-2015 at 07:36 PM.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

+ 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. breakpoint adds lines to code when I run the code
    By Erikje in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2013, 02:35 AM
  2. Replies: 4
    Last Post: 06-28-2012, 12:42 AM
  3. Understanding 2 lines of code
    By rmb623 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2011, 04:00 PM
  4. [SOLVED] How to see how many lines of code ?
    By SpookiePower in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2006, 11:10 PM
  5. Code to write out all lines of code
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-04-2005, 11:26 PM

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