Creating a List from a Table

ndbennett

New Member
Joined
Jul 14, 2017
Messages
17
Hi - my company supplies various groceries to multiple stores. Our inventory analyst visits the stores and prepares a table like the following, that we use to prepare the orders for dispatch:
Store 1 Store 2 Store 3 Store 4
Product A 1 3
Product B 5 5
Product C 7 9
Product D 2

We use Access as an inventory management tool and currently manually copy the order data into it, but I would like to append via an upload. Can anyone advise whether is is possible to automatically convert the above table into a list like the following, and if so, how?

Store Product Count
Store 1 Product A 1
Store 1 Product D 2
Store 2 Product B 5
Store 3 Product A 3
Store 3 Product B 5
Store 3 Product C 7
Store 4 Product C 9

Thanks!
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi ND,

I 'd recommend that you consider this to be a small commercial request (it will save your business significant money by reducing labour costs every time orders are processed), but all answers given here are voluntary.

Suffice to say that it would be quite straight-forward to create a single-step function to do what you want which would take less than a couple of seconds to turn the input data table into the list you are looking for. (There's no single-step Excel function/process to do what you want, although it could be done by a number of steps / formulas).

Feel free to ask for more info if you like. :)

Cheers,
Warren K
 
Upvote 0
It isn't clear if you are looking for a formula approach or a macro, so here is a suggestion for each.

Formula
Each formula copied down as far as you might need

Excel Workbook
ABCDE
1Store 1Store 2Store 3Store 4
2Product A13
3Product B55
4Product C79
5Product D2
6
7
8Store 1Product A1
9Store 1Product D2
10Store 2Product B5
11Store 3Product A3
12Store 3Product B5
13Store 3Product C7
14Store 4Product C9
15
Table to List Formula




Macro
With data starting in column A/row 1 as in A1:E5 below, try (in a copy of your workbook)
Code:
Sub Make_List()
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, k As Long
  
  a = Range("A1").CurrentRegion.Value
  ReDim b(1 To UBound(a, 1) * UBound(a, 2), 1 To 3)
  For j = 2 To UBound(a, 2)
    For i = 2 To UBound(a, 1)
      If Not IsEmpty(a(i, j)) Then
        k = k + 1
        b(k, 1) = a(1, j): b(k, 2) = a(i, 1): b(k, 3) = a(i, j)
      End If
    Next i
  Next j
  Range("A" & Rows.Count).End(xlUp).Offset(3).Resize(k, UBound(b, 2)).Value = b
End Sub

Data in rows 8, 9, 10, ... below was produced by the above code.

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="text-align: right;;"></td><td style="text-align: center;;">Store 1</td><td style="text-align: center;;">Store 2</td><td style="text-align: center;;">Store 3</td><td style="text-align: center;;">Store 4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Product A</td><td style="text-align: center;;">1</td><td style="text-align: center;;"></td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Product B</td><td style="text-align: center;;"></td><td style="text-align: center;;">5</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">Product C</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;">7</td><td style="text-align: center;;">9</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">Product D</td><td style="text-align: center;;">2</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style="text-align: right;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style=";">Store 1</td><td style="text-align: center;;">Product A</td><td style="text-align: center;;">1</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style=";">Store 1</td><td style="text-align: center;;">Product D</td><td style="text-align: center;;">2</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style=";">Store 2</td><td style="text-align: center;;">Product B</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">11</td><td style=";">Store 3</td><td style="text-align: center;;">Product A</td><td style="text-align: center;;">3</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">12</td><td style=";">Store 3</td><td style="text-align: center;;">Product B</td><td style="text-align: center;;">5</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">13</td><td style=";">Store 3</td><td style="text-align: center;;">Product C</td><td style="text-align: center;;">7</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">14</td><td style=";">Store 4</td><td style="text-align: center;;">Product C</td><td style="text-align: center;;">9</td><td style="text-align: center;;"></td><td style="text-align: center;;"></td></tr></table><p style="width:13.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Table to List vba</p>
 
Last edited:
Upvote 0
Solution
Thank you so much for your input, much appreciated - and apologies for the horrible formatting on my original question.
 
Upvote 0
Hi Walter, I agree that long term, professional automation is the way to go, but our budget is limited and the team still cling to their pens and paper. But Excel and Access are big steps forward for us! Thanks for taking the time to respond. :)
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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