+ Reply to Thread
Results 1 to 2 of 2

Create new rows based on numbers in cells

Hybrid View

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    15

    Create new rows based on numbers in cells

    Hello,

    I am hoping to redesign the way I use Excel to keep inventory of things. Currently we have one row for every type of part, but I want to change it so that there is one row for every individual physical item. Example:

    Current system:
    Part Made By Quantity On Hand
    Part A Company 1 3
    Part B Company 1 1
    Part C Company 2 2

    Desired:
    Part Made By Quantity On Hand
    Part A Company 1
    Part A Company 1
    Part A Company 1
    Part B Company 1
    Part C Company 2
    Part C Company 2

    So what the macro would need to do is insert n-1 rows beneath each initial row, where n is the current quantity on hand (stored in column C), and then copies down the part name and manufacturer. Is it possible to write a macro that is capable of doing that?

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Create new rows based on numbers in cells

    Sub expand()
    r = 3
    While Sheets(1).Cells(r, 1) <> ""
      j = Sheets(1).Cells(r, 3)
      If j > 1 Then
        For r2 = 2 To j
          Rows(r + 1 & ":" & r + 1).Select
          Application.CutCopyMode = False
          Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
          Sheets(1).Cells(r, 3) = 1
          For x = 1 To 3
            Sheets(1).Cells(r + 1, x) = Sheets(1).Cells(r, x)
          Next x
        Next r2
    End If
    r = r + j
    Wend
    
    
    End Sub

+ 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. Replies: 7
    Last Post: 02-27-2014, 10:56 PM
  2. Replies: 10
    Last Post: 11-13-2013, 09:01 PM
  3. Replies: 1
    Last Post: 10-16-2013, 02:46 PM
  4. Replies: 13
    Last Post: 04-18-2013, 12:32 PM
  5. Create new rows based on multiple cells on single row
    By julesie in forum Excel General
    Replies: 0
    Last Post: 10-20-2010, 02:10 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