+ Reply to Thread
Results 1 to 7 of 7

VBA code to copy and past rows of data

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    VBA code to copy and past rows of data

    Hi guys,

    hope fully I can explain this so you understand.....

    I have a spreadsheet which manages raw material ordering for a factory. There is over 300 SKU's in the sheet and i am looking for a way to automate copying and pasting data from one row to the next for each SKU.
    I have created a simplified version and attached it.
    Basically for each item I want the code go though each SKU and copy the suggestion line and past values into the requested line
    so:
    E8:V8 copy, E9:V9 paste values
    E21:V21 copy, E22:V22 paste values
    E35:V35 copy, E36:V36 paste values

    I appreciate you can do the brut force approach and just type this into the code (i.e. specifying which rows and columns to copy and paste) but due to the amount of SKU's in the spreadsheet and the number of tabs they are over it would be difficult to set up and maintain.
    I was wondering if there was a smart way to set a macro up to do this - as in it cycles through a range of data looking for a trigger maybe in each sku which would cause it to copy and paste the data?!

    Thoughts?
    Thanks in advance,
    Tom.
    Attached Files Attached Files

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: VBA code to copy and past rows of data

    You can look for the "Requested" row and then do something.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: VBA code to copy and past rows of data

    Quote Originally Posted by davesexcel View Post
    You can look for the "Requested" row and then do something.

    Please Login or Register  to view this content.
    Hi, thanks for that it worked a treat.
    If I want this to work over a few worksheets how would the code look then (if we assume the are worksheet A,B and C)?

    Many thanks,
    Tom

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: VBA code to copy and past rows of data

    Looping through the sheets.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: VBA code to copy and past rows of data

    brilliant thanks.
    Last question hopefully....
    If I wanted to make the range dynamic i.e. so it isn't Row E to Row V everytime, what is the best way to do this? Can you specifiy the columns in a 2 cells on the sheet somewhere I.e. A1 and A2? Or could it be done by a question asked in a text box when the macro runs?
    Many thanks,
    Tom.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: VBA code to copy and past rows of data

    Maybe finding the last column in the sheet will do it.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-05-2012
    Location
    liverpool
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: VBA code to copy and past rows of data

    thank you, i'll give it a go!

+ 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 rows out of a datasheet based on a code number and past these rows in a new sheet
    By Robert1311 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-11-2018, 11:41 AM
  2. VBA code to Copy and Past values into the next available cell
    By sx200n in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2017, 11:33 AM
  3. Advice and help with a copy past code or filldown formula code
    By KELLIS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2013, 02:07 PM
  4. [SOLVED] copy past transpose code error
    By anilg0001 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2013, 05:14 AM
  5. I am trying to copy rows of data from certain columns and past in another worksheet
    By datathumper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2012, 01:28 PM
  6. function/formula to copy/past multiple data rows in Excel worksheet
    By djerin in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-22-2009, 09:16 AM
  7. problem with code. past link instead of copy
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-20-2006, 04:00 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