Multiple Columns With the Same Items to Sum

AKFlyer

New Member
Joined
Nov 26, 2006
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm trying to find a way to sum the amount of needed materials based on what Item(s) I choose/filter by. In other words, if I want to build Items 1 and 5 in the first box below, I would need a total of 1 Copper, 3 Silver, 2 Iron, 6 Gold. I want to choose/filter by the items I'm looking for, and have it display only one instance of each material and the sum of that material I need. Something like the second box below.

I've tried Pivot Table, Sumifs, Filtering, and a couple other dumb ideas but can't seem to get it to work. I'd say I'm above average on my Excel knowledge but some things just stump me. I appreciate any help or suggestions!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Yeah, sorry. I'm a dummy.

Screenshot 2023-09-17 153758.jpg
 
Upvote 0
I'm sure there'll be a formula answer to this, but this is the best I could come up with. Uses a UDF, and conditional formatting.
UDF (pu in a standard module)
VBA Code:
Function SumMat(r As Range, s As String) As Long
    Dim c As Range, x As Long
    For Each c In r
        If c.EntireRow.Hidden = False And c = s Then x = x + c.Offset(0, 1)
    Next c
    SumMat = x
End Function

Before applying the filter:
Book1
ABCDEFG
1ITEMMaterialAmtMaterialAmtMaterialAmt
2Item 1Copper1Silver2
3Item 2Silver3Gold1Iron1
4Item 3Iron2Nickel5Silver2
5Item 4Nickel2Copper1
6Item 5Silver1Iron2Gold6
7
8
9MaterialAmt
10Copper2
11Gold7
12Iron5
13Nickel7
14Silver8
15
Sheet1
Cell Formulas
RangeFormula
C10:C14C10=SumMat($B$2:$G$6,B10)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B10:B14Expression=C10=0textNO
C10:C14Cell Value=0textNO


After applying the filter:
Book1
ABCDEFG
1ITEMMaterialAmtMaterialAmtMaterialAmt
2Item 1Copper1Silver2
6Item 5Silver1Iron2Gold6
7
8
9MaterialAmt
10Copper1
11Gold6
12Iron2
13Nickel0
14Silver3
15
Sheet1
Cell Formulas
RangeFormula
C10:C14C10=SumMat($B$2:$G$6,B10)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B10:B14Expression=C10=0textNO
C10:C14Cell Value=0textNO
 
Upvote 0
Solution
I'm sure there'll be a formula answer to this, but this is the best I could come up with. Uses a UDF, and conditional formatting.
UDF (pu in a standard module)
VBA Code:
Function SumMat(r As Range, s As String) As Long
    Dim c As Range, x As Long
    For Each c In r
        If c.EntireRow.Hidden = False And c = s Then x = x + c.Offset(0, 1)
    Next c
    SumMat = x
End Function

Before applying the filter:
Book1
ABCDEFG
1ITEMMaterialAmtMaterialAmtMaterialAmt
2Item 1Copper1Silver2
3Item 2Silver3Gold1Iron1
4Item 3Iron2Nickel5Silver2
5Item 4Nickel2Copper1
6Item 5Silver1Iron2Gold6
7
8
9MaterialAmt
10Copper2
11Gold7
12Iron5
13Nickel7
14Silver8
15
Sheet1
Cell Formulas
RangeFormula
C10:C14C10=SumMat($B$2:$G$6,B10)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B10:B14Expression=C10=0textNO
C10:C14Cell Value=0textNO


After applying the filter:
Book1
ABCDEFG
1ITEMMaterialAmtMaterialAmtMaterialAmt
2Item 1Copper1Silver2
6Item 5Silver1Iron2Gold6
7
8
9MaterialAmt
10Copper1
11Gold6
12Iron2
13Nickel0
14Silver3
15
Sheet1
Cell Formulas
RangeFormula
C10:C14C10=SumMat($B$2:$G$6,B10)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B10:B14Expression=C10=0textNO
C10:C14Cell Value=0textNO

This works for what I need, thank you!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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