+ Reply to Thread
Results 1 to 5 of 5

Copy/Paste Loop Macro

  1. #1
    Registered User
    Join Date
    01-11-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    38

    Copy/Paste Loop Macro

    I am trying to create a macro to copy data from one sheet to another. The first sheet has data that has been entered and the second sheet is used organize the data so it can be used to make calculations and graphs from the data. The problem that I am having now is being able to loop through all of the lines of the entered data in order to copy it to the second sheet from which the data is used.
    The data in "Enter Data" is in entries of 9 rows by 27 columns (A2:AA10) and the converted code ("Hr-by-Hr Chart Data") is 30 rows by 20+ columns. I am using column B, first row of each data entry in Enter Data, and column A, first empty row in Converted Data, as the baseline boxes from which ranges are selected relative to because there will always be data for the cells in those columns, while there may or may not be data in most of the rest... if that all makes sense.
    Here is the declaring and looping parts of my code:

    Please Login or Register  to view this content.
    I have only been working with excel for a few weeks so I am still trying to learn the code and how to do relatively simple things like using variables correctly and looping correctly, so please let me know if I am doing anything that I really shouldn't do or if there is a better way to do it.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Copy/Paste Loop Macro

    I'm not sure I follow what you want to achieve. Perhaps this will give you some ideas.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 06-14-2012 at 02:06 PM.

  3. #3
    Registered User
    Join Date
    01-11-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Copy/Paste Loop Macro

    That is very good. I was not sure what would be the best way to set up the loop.
    Just out of curiosity, why would you choose to use a 'for' loop instead of a 'do until isempty' loop?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Copy/Paste Loop Macro

    You're welcome.

    Quote Originally Posted by danderson2692 View Post
    ...why would you choose to use a 'for' loop instead of a 'do until isempty' loop?
    No major reason. Personal preference I guess. A For\Next loop does allow for a Step size in the one line of code.

    Your original code was pretty good. The actual "Loop" wasn't much of an issue. Most improvements in the new code were in how Sheets and Ranges wre referenced.

  5. #5
    Registered User
    Join Date
    01-11-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: Copy/Paste Loop Macro

    Ok. Thanks for the help!

+ 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