Creating a Summary Worksheet

rjenk

New Member
Joined
Mar 10, 2017
Messages
9
I have a spreadsheet that has two tabs, one is a Summary while the other is a WORK LOAD tab.

The WORK LOAD tab has an Item #, Item Type, Location, and Notes columns. The Item # column has various two to four digit item numbers, they Item Type has up to ten types, and the Location tab is either Shop or Vendor.

On the Summary tab, I am trying to summarize by Location, by Item Type (cell A) and then just list the Item #s separated by a comma (cell B).

Example would be:

Shop Items

Truck | 31, 46
Car | 2415, 2788
Trailer | 4183, 4188

Vendor Items:

Truck | 18, 24, 88
Car | 2111, 2218, 2844
Trailer | 4000


It is basically if Location=Shop and Item=Truck then put Item #'s in a cell separated by a comma...repeat for other combinations.

Hope that makes sense. I have a small sample spreadsheet available if that would help.

Thanks in advance for any assistance.

Ray
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Excel Workbook
ABCD
1Worklist
2
3EquiptmentNumberEquiptmentTypeLocationNotes
424TruckShop
531TruckVendor
646TruckVendor
799TruckShop
81121LiftShop
91233LiftShop
102415CarVendor
112655CarShop
122788CarVendor
134183TrailerVendor
144188TrailerVendor
154199TrailerShop
WORK LOAD
 
Upvote 0
Excel Workbook
AB
1Summary
2
3Unavailable (Shop Repair)
4Truck
5Lift
6Car
7Trailer
8
9Unavailable (Vendor Repair)
10Truck
11Lift
12Car
13Trailer
14
15
16Example Format Below
17
18Unavailable (Vendor Repair)
19Truck31, 46
20Lift
21Car2415, 2788
22Trailer4183, 4188
23
Summary
 
Upvote 0
Thanks for the samples, are you looking for formulae, or VBA, or don't you mind?

Also, for future reference there is a test board here https://www.mrexcel.com/forum/test-here/
where you can test things out to your hearts content, without cluttering up the main board.
I've removed your 1st two attempts.
 
Upvote 0
Thanks for removing the errors.

I had been trying to do it with formulae, but not opposed to VBA.
 
Upvote 0
How about
Code:
Sub CreateSummary()

   Dim Cl As Range
   Dim Dic(1 To 2) As Object
   Dim Sws As Worksheet
   Dim Dws As Worksheet
   Dim i As Long
   Dim Rw As Long
   
   Set Sws = Sheets("Work load")
   Set Dws = Sheets("Summary")
   For i = 1 To 2
      Set Dic(i) = CreateObject("scripting.dictionary")
      Dic(i).comparemode = vbTextCompare
   Next i
   For Each Cl In Sws.Range("B4", Sws.Range("B" & Rows.Count).End(xlUp))
      If Cl.Offset(, 1).Value = "Shop" Then
         i = 1
      ElseIf Cl.Offset(, 1).Value = "Vendor" Then
         i = 2
      End If
      If Not Dic(i).exists(Cl.Value) Then
         Dic(i).Add Cl.Value, Cl.Offset(, -1).Value
      Else
         Dic(i).Item(Cl.Value) = Dic(i).Item(Cl.Value) & ", " & Cl.Offset(, -1).Value
      End If
   Next Cl
   For Rw = 4 To Dws.Range("A4").End(xlDown).Row
      Dws.Range("B" & Rw).Value = Dic(1).Item(Dws.Range("A" & Rw).Value)
   Next Rw
   For Rw = 10 To Dws.Range("A10").End(xlDown).Row
      Dws.Range("B" & Rw).Value = Dic(2).Item(Dws.Range("A" & Rw).Value)
   Next Rw

End Sub
This should work on the sample you've shown, but you'll probably need to change the values in red, for your real sheet.

EDIT: I've changed the code to make it case insensitive
 
Last edited:
Upvote 0
Thanks so much, that worked perfect. I really appreciate it.

In my actual spreadsheet, the Shop/Vendor column is K and the summary sections start on A21 (for Shop) and A29 (for Vendor). Can you instruct me on the changes to the script based on those differences? I have been tinkering around, but have not quite figured it out.
 
Upvote 0
Figured it out and have it working...much, much thanks! Had the change the offset to get to column K and change starting rows for the two sections.

Thanks again!
 
Upvote 0
Glad you figured it out & thanks for the feedback.

It would have helped, If I had remembered to add the values in red after posting the modified!
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,030
Members
448,940
Latest member
mdusw

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