+ Reply to Thread
Results 1 to 4 of 4

Excel VBA/Macro - Copy Number of Rows based on the number in a cell to another sheet

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    Amherst, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    4

    Excel VBA/Macro - Copy Number of Rows based on the number in a cell to another sheet

    I would like to copy a row the number of times that is based on the cell within that row from Sheet 1 to Sheet 2. The number of rows I need copied is determined in cell D, which contains a number. So if the number is 2, I need that row to be copied twice. If the number is 3, it would need to be copied three times. The spreadsheet is listed below and the column is called Room Capacity.

    Sheet1 looks like this:

    Building Desc Room Item ID Room Capacity
    Baker 0010 16X-009 2
    Baker 0340 16X-156 2
    Brett 0207 27X-129 2
    Brett 0237 27X-030 2
    Brett 0137 27X-149 3
    Brooks 0207 27X-256 2
    Brooks 0308 27X-263 2
    Brown 0705B 09X-207 1
    Brown 0705E 09X-208 1
    Brown 0705D 09X-209 2
    Brown 0304C 09X-112 2
    Butterfield 0105 13X-055 1
    Butterfield 0329 13X-069 2
    Butterfield 0111 13X-027 2
    Butterfield 0113 13X-024 1
    Butterfield 0318 13X-051 1
    Butterfield 0101 13X-088 3
    Butterfield 0215 13X-072 3
    Cance 0352 06X-061 4
    Cance 0206 06X-006 2
    Cance 0224 06X-095 2
    Cance 0458 06X-195 2
    Cance 0218 06X-045 2
    Cance 0204 06X-178 2
    Cance 0308 06X-174 2
    Cance 0461 06X-046 2
    Cance 0026 06X-142 2
    Cance 0427 06X-086 3
    Cance 0452 06X-059 4

    Can anyone help?

    Thank you!

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: Excel VBA/Macro - Copy Number of Rows based on the number in a cell to another sheet

    I think this will do what you want.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-31-2012
    Location
    Amherst, Massachusetts
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Excel VBA/Macro - Copy Number of Rows based on the number in a cell to another sheet

    I thought I thanked you, but I guess I hit the wrong thing to reply. This macro worked extremely well and I want to thank you for all of your help with this!

  4. #4
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Excel VBA/Macro - Copy Number of Rows based on the number in a cell to another sheet

    @ diane.alexander58

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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