Row additions in relation to a cell's value.

MichaelNeedsHelp

New Member
Joined
Mar 23, 2011
Messages
3
I have a database that displays "Product Name" in column A and "Number of Products Available" in column B.

Example:

productnameandnumber.jpg


My goal is to make a list that displays each individual product, creating the correct number of rows for each type of product.

Example:

productsavailable.jpg


Any suggestions on the best way to solve this problem are greatly appreciated. Thank you!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
The only way I can think of is through the use of macros.

You could right-click the sheet that contains your data, left-click "View Code" and paste the following in the window that appears:

Code:
Sub MichaelNeedsHelp()
Dim myRowCtr1 As Long, myRowCtr2 As Long, myRows As Long, n As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = ActiveSheet
Set ws2 = Sheets.Add
myRowCtr1 = 2
myRowCtr2 = 9
ws2.Cells(8, 1) = "Products Available"
Do
    myRows = ws1.Cells(myRowCtr1, 2).Value
    For n = 1 To myRows
        ws2.Cells(myRowCtr2, 1).Value = ws1.Cells(myRowCtr1, 1).Value
        myRowCtr2 = myRowCtr2 + 1
    Next
    myRowCtr1 = myRowCtr1 + 1
Loop Until ws1.Cells(myRowCtr1, 1) = ""
    
End Sub

Running this macro would insert a new sheet and populate it with data in column A, row 8 onwards as you desire.
 
Upvote 0
Wow! Thank you so much. I would have never figured that out on my own! This is exactly what I needed. Really appreciate the quick help!:biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,310
Members
452,906
Latest member
phanmemchatdakenhupviral

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top