+ Reply to Thread
Results 1 to 12 of 12

Macro - Create / Copy / Paste Formula every 5 rows for varying range

  1. #1
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Macro - Create / Copy / Paste Formula every 5 rows for varying range

    We have a file that exports to excel badly. We have the need to create a formula to copy A6 & B6 to K3 & L3, THEN copy this formula down K & L through the length of data on the current sheet.

    The 2 problems are;

    1. There are 5 blank rows between each formula

    2. There is a varying length of data at each run - we can use column C to indicate length

    Any advice would be greatly appreciated.

    Thanks,

    Jill
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    It would be easier if there was a sample workbook, but you could try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Sorry, I have attached the spreadsheet. Values at A6 and B6 should be at K3 and L3. I need to copy this down through the end of the document - paste values - and, further sort and delete the rogue data in columns A & B.

    Thanks,

    Jill
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Next time, don't attach a picture please. People have to recreate your scenario themselves.
    Attach a workbook instead.

    Please Login or Register  to view this content.
    I guess I am not the only one re attachment.

  6. #6
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Jolivanes,

    Thanks, this works, though I wish I understood it better. Any thoughts about removing the leftover data in columns A & B?

    Thanks Again,

    Jill

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    I don't know if you want to delete the empty rows but if you do you could add this to the code.
    Make sure you try it on a copy of your workbook in case it is not what you want.

    Please Login or Register  to view this content.
    Put this line between "Next i" and "End Sub"

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    My bad. I misread your requirements.
    Try this instead. Again, on a copy of your workbook.
    If you don't want the empties deleted, delete the line before "End Sub".

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Awesome, that worked great! Though, now I have noticed that the values copied to columns K and L are all the same. There are values in Columns A and B for each row that contains data. What are your thoughts about this?

    I appreciate your help with this.

    --Jill

  10. #10
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    This works great. Thank you so much for your assistance!

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    That is a Cell Format problem Jill.
    Try this. (On a copy of your WB again)
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    01-13-2004
    Posts
    17

    Re: Macro - Create / Copy / Paste Formula every 5 rows for varying range

    Thanks again!

+ 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. Macro required for copy a range, create a new txt file and paste it
    By gm2612 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-28-2013, 07:25 AM
  2. Create a Macro to perform a custom sort on varying number of rows
    By Shirley Munro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2013, 07:09 PM
  3. Copy and paste list with varying length to specific columns/rows
    By bruizer31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 08:32 PM
  4. create macro to copy paste many rows at once
    By asaya in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2008, 03:47 PM
  5. [SOLVED] I need formula help or create a macro to copy and paste value only
    By Rebecca in forum Excel General
    Replies: 4
    Last Post: 04-08-2006, 08:25 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