filter data based on multiple price for each sheet based on two columns

Ali M

Active Member
Joined
Oct 10, 2021
Messages
348
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
hi experts

I hope finding solution here . despite of my request is not easy .
so I have data in sheet MAIN. what I want filter data based on column B ,G for each sheet with just merge and sum duplicate item based on column B in column F and column H= column FxG
it shouldn't merge column H,G . I put the formula in column H how calculate, but I don't want show the formula in column H .
so in sheet BIG should merge duplicate items based on column B and bring big price based on column G as I highlighted by red color
also in sheet SMALL should merge duplicate items based on column B and bring small price based on column G as I highlighted by red color
the same thing in sheet AVERAGE should merge duplicate items based on column B and average price based on column G as I highlighted by red color

NOTE: my data are about 1000 rows in sheet main and it's increasable
Pri.xlsm
ABCDEFGH
1DATESSTRTTRMMRNNRQTYPRICETOTAL
207/08/2021SLFR-100FOOD-1PR100NRIT110.0025.00250.00
308/08/2021SLFR-101FOOD-2PR101NRIT220.0030.00600.00
409/08/2021SLFR-102FOOD-3PR102NRIT323.0035.00805.00
510/08/2021SLFR-103FOOD-4PR103NRIT425.0030.00750.00
611/08/2021SLFR-104FOOD-5PR104NRIT520.0040.00800.00
712/08/2021SLFR-105FOOD-6PR105NRIT610.0045.00450.00
813/08/2021SLFR-106FOOD-7PR106NRIT720.0045.00900.00
914/08/2021SLFR-107FOOD-8PR107NRIT815.0055.00825.00
1015/08/2021SLFR-108FOOD-9PR108NRIT95.0060.00300.00
1116/08/2021SLFR-109FOOD-10PR109NRIT1010.0070.00700.00
1217/08/2021SLFR-110FOOD-11PR110NRIT1120.0080.001,600.00
1318/08/2021SLFR-111FOOD-12PR111NRIT1225.0085.002,125.00
1419/08/2021SLFR-112FOOD-13PR112NRIT1320.0090.001,800.00
1520/08/2021SLFR-113FOOD-14PR113NRIT1420.0025.00500.00
1621/08/2021SLFR-114FOOD-15PR114NRIT1510.0030.00300.00
1722/08/2021SLFR-115FOOD-16PR115NRIT1610.0045.00450.00
1823/08/2021SLFR-116FOOD-17PR116NRIT1710.0040.00400.00
1924/08/2021SLFR-117FOOD-18PR117NRIT1815.0050.00750.00
2025/08/2021SLFR-118FOOD-19PR118NRIT1915.0060.00900.00
2126/08/2021SLFR-119FOOD-20PR119NRIT205.0045.00225.00
2227/08/2021SLFR-115FOOD-16PR116NRIT175.0020.00100.00
2328/08/2021SLFR-116FOOD-17PR117NRIT1810.0035.00350.00
2429/08/2021SLFR-117FOOD-18PR118NRIT1920.0050.001,000.00
2530/08/2021SLFR-118FOOD-19PR119NRIT2010.0045.00450.00
2631/08/2021SLFR-119FOOD-20PR120NRIT2120.0025.00500.00
2701/09/2021SLFR-120FOOD-21PR121NRIT2210.0020.00200.00
2802/09/2021SLFR-121FOOD-22PR122NRIT235.0020.00100.00
2903/09/2021SLFR-122FOOD-23PR123NRIT2420.0025.00500.00
MAIN
Cell Formulas
RangeFormula
H2:H29H2=F2*G2


Pri.xlsm
ABCDEFGH
1ITEMSSTRTTRMMRNNRQTYPRICETOTAL
21SLFR-100FOOD-1PR100NRIT110.0025.00250.00
32SLFR-101FOOD-2PR101NRIT220.0030.00600.00
43SLFR-102FOOD-3PR102NRIT323.0035.00805.00
54SLFR-103FOOD-4PR103NRIT425.0030.00750.00
65SLFR-104FOOD-5PR104NRIT520.0040.00800.00
76SLFR-105FOOD-6PR105NRIT610.0045.00450.00
87SLFR-106FOOD-7PR106NRIT720.0045.00900.00
98SLFR-107FOOD-8PR107NRIT815.0055.00825.00
109SLFR-108FOOD-9PR108NRIT95.0060.00300.00
1110SLFR-109FOOD-10PR109NRIT1010.0070.00700.00
1211SLFR-110FOOD-11PR110NRIT1120.0080.001,600.00
1312SLFR-111FOOD-12PR111NRIT1225.0085.002,125.00
1413SLFR-112FOOD-13PR112NRIT1320.0090.001,800.00
1514SLFR-113FOOD-14PR113NRIT1420.0025.00500.00
1615SLFR-114FOOD-15PR114NRIT1510.0030.00300.00
1716SLFR-115FOOD-16PR115NRIT1615.0045.00675.00
1817SLFR-116FOOD-17PR116NRIT1720.0040.00800.00
1918SLFR-117FOOD-18PR117NRIT1835.0050.001,750.00
2019SLFR-118FOOD-19PR118NRIT1925.0060.001,500.00
2120SLFR-119FOOD-20PR119NRIT2025.0045.001,125.00
2221SLFR-120FOOD-21PR121NRIT2210.0020.00200.00
2322SLFR-121FOOD-22PR122NRIT235.0020.00100.00
2423SLFR-122FOOD-23PR123NRIT2420.0025.00500.00
BIG
Cell Formulas
RangeFormula
H2:H24H2=F2*G2



Pri.xlsm
ABCDEFGH
1ITEMSSTRTTRMMRNNRQTYPRICETOTAL
21SLFR-100FOOD-1PR100NRIT110.0025.00250.00
32SLFR-101FOOD-2PR101NRIT220.0030.00600.00
43SLFR-102FOOD-3PR102NRIT323.0035.00805.00
54SLFR-103FOOD-4PR103NRIT425.0030.00750.00
65SLFR-104FOOD-5PR104NRIT520.0040.00800.00
76SLFR-105FOOD-6PR105NRIT610.0045.00450.00
87SLFR-106FOOD-7PR106NRIT720.0045.00900.00
98SLFR-107FOOD-8PR107NRIT815.0055.00825.00
109SLFR-108FOOD-9PR108NRIT95.0060.00300.00
1110SLFR-109FOOD-10PR109NRIT1010.0070.00700.00
1211SLFR-110FOOD-11PR110NRIT1120.0080.001,600.00
1312SLFR-111FOOD-12PR111NRIT1225.0085.002,125.00
1413SLFR-112FOOD-13PR112NRIT1320.0090.001,800.00
1514SLFR-113FOOD-14PR113NRIT1420.0025.00500.00
1615SLFR-114FOOD-15PR114NRIT1510.0030.00300.00
1716SLFR-115FOOD-16PR115NRIT1615.0020.00300.00
1817SLFR-116FOOD-17PR116NRIT1720.0035.00700.00
1918SLFR-117FOOD-18PR117NRIT1835.0050.001,750.00
2019SLFR-118FOOD-19PR118NRIT1925.0045.001,125.00
2120SLFR-119FOOD-20PR119NRIT2025.0025.00625.00
2221SLFR-120FOOD-21PR121NRIT2210.0020.00200.00
2322SLFR-121FOOD-22PR122NRIT235.0020.00100.00
2423SLFR-122FOOD-23PR123NRIT2420.0025.00500.00
SMALL
Cell Formulas
RangeFormula
H2:H24H2=F2*G2



Pri.xlsm
ABCDEFGH
1ITEMSSTRTTRMMRNNRQTYPRICETOTAL
21SLFR-100FOOD-1PR100NRIT110.0025.00250.00
32SLFR-101FOOD-2PR101NRIT220.0030.00600.00
43SLFR-102FOOD-3PR102NRIT323.0035.00805.00
54SLFR-103FOOD-4PR103NRIT425.0030.00750.00
65SLFR-104FOOD-5PR104NRIT520.0040.00800.00
76SLFR-105FOOD-6PR105NRIT610.0045.00450.00
87SLFR-106FOOD-7PR106NRIT720.0045.00900.00
98SLFR-107FOOD-8PR107NRIT815.0055.00825.00
109SLFR-108FOOD-9PR108NRIT95.0060.00300.00
1110SLFR-109FOOD-10PR109NRIT1010.0070.00700.00
1211SLFR-110FOOD-11PR110NRIT1120.0080.001,600.00
1312SLFR-111FOOD-12PR111NRIT1225.0085.002,125.00
1413SLFR-112FOOD-13PR112NRIT1320.0090.001,800.00
1514SLFR-113FOOD-14PR113NRIT1420.0025.00500.00
1615SLFR-114FOOD-15PR114NRIT1510.0030.00300.00
1716SLFR-115FOOD-16PR115NRIT1615.0032.50487.50
1817SLFR-116FOOD-17PR116NRIT1720.0037.50750.00
1918SLFR-117FOOD-18PR117NRIT1835.0050.001,750.00
2019SLFR-118FOOD-19PR118NRIT1925.0052.501,312.50
2120SLFR-119FOOD-20PR119NRIT2025.0035.00875.00
2221SLFR-120FOOD-21PR121NRIT2210.0020.00200.00
2322SLFR-121FOOD-22PR122NRIT235.0020.00100.00
2423SLFR-122FOOD-23PR123NRIT2420.0025.00500.00
AVERAGE
Cell Formulas
RangeFormula
H2:H24H2=F2*G2
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Do you really need it to be spread over multiple sheets with the duplicates removed? It can be done, but simply adding extra columns to the main sheet as below will be a much easier and more efficient way of getting the results.
Book2
ABCDEFGHIJK
1DATESSTRTTRMMRNNRQTYPRICETOTALBigSmallAverage
207/08/2021SLFR-100FOOD-1PR100NRIT110.0025.00250.0025.0025.0025.00
308/08/2021SLFR-101FOOD-2PR101NRIT220.0030.00600.0030.0030.0030.00
409/08/2021SLFR-102FOOD-3PR102NRIT323.0035.00805.0035.0035.0035.00
510/08/2021SLFR-103FOOD-4PR103NRIT425.0030.00750.0030.0030.0030.00
611/08/2021SLFR-104FOOD-5PR104NRIT520.0040.00800.0040.0040.0040.00
712/08/2021SLFR-105FOOD-6PR105NRIT610.0045.00450.0045.0045.0045.00
813/08/2021SLFR-106FOOD-7PR106NRIT720.0045.00900.0045.0045.0045.00
914/08/2021SLFR-107FOOD-8PR107NRIT815.0055.00825.0055.0055.0055.00
1015/08/2021SLFR-108FOOD-9PR108NRIT95.0060.00300.0060.0060.0060.00
1116/08/2021SLFR-109FOOD-10PR109NRIT1010.0070.00700.0070.0070.0070.00
1217/08/2021SLFR-110FOOD-11PR110NRIT1120.0080.001600.0080.0080.0080.00
1318/08/2021SLFR-111FOOD-12PR111NRIT1225.0085.002125.0085.0085.0085.00
1419/08/2021SLFR-112FOOD-13PR112NRIT1320.0090.001800.0090.0090.0090.00
1520/08/2021SLFR-113FOOD-14PR113NRIT1420.0025.00500.0025.0025.0025.00
1621/08/2021SLFR-114FOOD-15PR114NRIT1510.0030.00300.0030.0030.0030.00
1722/08/2021SLFR-115FOOD-16PR115NRIT1610.0045.00450.0045.0020.0032.50
1823/08/2021SLFR-116FOOD-17PR116NRIT1710.0040.00400.0040.0035.0037.50
1924/08/2021SLFR-117FOOD-18PR117NRIT1815.0050.00750.0050.0050.0050.00
2025/08/2021SLFR-118FOOD-19PR118NRIT1915.0060.00900.0060.0045.0052.50
2126/08/2021SLFR-119FOOD-20PR119NRIT205.0045.00225.0045.0025.0035.00
2227/08/2021SLFR-115FOOD-16PR116NRIT175.0020.00100.0045.0020.0032.50
2328/08/2021SLFR-116FOOD-17PR117NRIT1810.0035.00350.0040.0035.0037.50
2429/08/2021SLFR-117FOOD-18PR118NRIT1920.0050.001000.0050.0050.0050.00
2530/08/2021SLFR-118FOOD-19PR119NRIT2010.0045.00450.0060.0045.0052.50
2631/08/2021SLFR-119FOOD-20PR120NRIT2120.0025.00500.0045.0025.0035.00
2701/09/2021SLFR-120FOOD-21PR121NRIT2210.0020.00200.0020.0020.0020.00
2802/09/2021SLFR-121FOOD-22PR122NRIT235.0020.00100.0020.0020.0020.00
2903/09/2021SLFR-122FOOD-23PR123NRIT2420.0025.00500.0025.0025.0025.00
Sheet1
Cell Formulas
RangeFormula
H2:H29H2=F2*G2
I2:I29I2=MAXIFS(G:G,B:B,B2)
J2:J29J2=MINIFS(G:G,B:B,B2)
K2:K29K2=AVERAGEIFS(G:G,B:B,B2)
 
Upvote 0
thank for your answering
as i said
each sheet with just merge and sum duplicate item based on column B
should merege
NOTE: my data are about 1000 rows in sheet main and it's increasable
then should do that by macro
thanks
 
Upvote 0
Hi ALI M
If you still intrested
try
VBA Code:
Sub test()
Dim a As Variant
a = Sheets("main").Cells(1).CurrentRegion
With CreateObject("scripting.dictionary")
   For i = 2 To UBound(a)
        If Not .exists(a(i, 2)) Then
            .Add a(i, 2), Array(a(i, 2), a(i, 3), a(i, 4), a(i, 5), a(i, 6), a(i, 7), 0, 0, 0)
            w = .Item(a(i, 2))
            w(6) = a(i, 7): w(7) = a(i, 6): w(8) = a(i, 7)
            .Item(a(i, 2)) = w
        Else
            w = .Item(a(i, 2)): w(4) = w(4) + a(i, 6)
        If w(5) < a(i, 7) Then
            w(5) = w(5)
        Else
            If w(5) >= a(i, 7) Then
            w(6) = a(i, 7)
            End If
        w(8) = (w(5) + w(6)) / 2
        .Item(a(i, 2)) = w
        End If: End If
    Next
a = Application.Index(Evaluate("row(1:" & .Count & ")"), 0, 0)
Sheets("big").Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 6))
Sheets("big").Cells(1, 1).Resize(.Count) = a
Sheets("big").Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
Sheets("small").Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 7))
Sheets("small").Cells(1, 1).Resize(.Count) = a
Sheets("small").Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
Sheets("average").Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 9))
Sheets("average").Cells(1, 1).Resize(.Count) = a
Sheets("average").Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
End With
End Sub
 
Upvote 0
If you still intrested
surly yes . no body answers me so far . but your code starts sequence from row1 and delete header ITEM in A1 and replace of it number 1 ,also when show the values in the others sheets should show number format based on sheet MAIN . how should fix for these problems?
 
Upvote 0
Ok
code starts sequence from row1 and delete header ITEM in A1 and replace of it number 1
sorry it is miss typing fixed
number format
Fixed

VBA Code:
Sub test()
Dim a, w As Variant
Dim i As Long
Dim bsht As Worksheet: Dim ssht As Worksheet: Dim avsht As Worksheet
Set bsht = Sheets("Big"): Set ssht = Sheets("Small"): Set avsht = Sheets("Average")
a = Sheets("main").Cells(1).CurrentRegion
With CreateObject("scripting.dictionary")
   For i = 2 To UBound(a)
        If Not .exists(a(i, 2)) Then
            .Add a(i, 2), Array(a(i, 2), a(i, 3), a(i, 4), a(i, 5), a(i, 6), a(i, 7), 0, 0, 0)
            w = .Item(a(i, 2))
            w(6) = a(i, 7): w(7) = a(i, 6): w(8) = a(i, 7)
            .Item(a(i, 2)) = w
        Else
            w = .Item(a(i, 2)): w(4) = w(4) + a(i, 6)
        If w(5) < a(i, 7) Then
            w(5) = w(5)
        Else
            If w(5) >= a(i, 7) Then
            w(6) = a(i, 7)
            End If
        w(8) = (w(5) + w(6)) / 2
        .Item(a(i, 2)) = w
        End If: End If
    Next
a = Application.Index(Evaluate("row(1:" & .Count & ")"), 0, 0)
bsht.Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 6))
bsht.Cells(2, 1).Resize(.Count) = a
bsht.Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
ssht.Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 7))
ssht.Cells(2, 1).Resize(.Count) = a
ssht.Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
avsht.Cells(2, 2).Resize(.Count, 6) = Application.Index(.items, Evaluate("row(1:" & .Count & ")"), Array(1, 2, 3, 4, 5, 9))
avsht.Cells(2, 1).Resize(.Count) = a
avsht.Cells(2, 8).Resize(.Count) = "=RC[-2]*RC[-1]"
bsht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "0.00"
ssht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "0.00"
ssht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "0.00"
End With
End Sub
 
Upvote 0
Solution
you repeat the sheet twice about NumberFormat and doesn't work as What I want , But I can figure out how mod it .
VBA Code:
bsht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "#,##0.00"
ssht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "#,##0.00"
avsht.Cells(2, 6).Resize(.Count, 3).NumberFormat = "#,##0.00"
thanks so much buddy ! ;)
 
Upvote 0
You are welcome Ali M
Glade I could help
Miss typing as ever
Sorry for that as well
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
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