Multiple search criteria for copy and paste value in new sheet

CapricornDec20

New Member
Joined
Apr 18, 2021
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hello Guys
Please I am new to excel programming and would like to get started. Need help.
Can anyone help me with it, my boss gave an assignment I need to fill the final data sheet from the raw data sheet, if it have one search criteria for search and match i can use vlookup, but the problem is that its has 3 search criteria, City, store and day of the week. Can any one help me out for creating the excel macro, if data is short i can do it manually, but its a very huge data of 2000+ entries. data file is attached.

Test.JPG
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
try:
cell E20 =INDEX($D$5:$J$16,MATCH(1,INDEX(($A$5:$A$16=A20)*($B$5:$B$16=B20)*($C$5:$C$16=C20),0,1),0),MATCH(D20,$D$4:$J$4,0))
 
Upvote 0
Is this the right answer?
Test.xlsx
ABCDEFGHIJ
1MonthCitiesStoresMonday (Sale)Tuesday (Sale)Wednesday (Sale)Thursday (Sale)Friday (Sale)Saturday (Sale)Sunday (Sale)
2March'21KHI115112016252130
3March'21KHI220162521302635
4March'21KHI325213026353140
5March'21KHI430263531403645
6March'21KHI535314036454150
7March'21LHR140364541504655
8March'21LHR245415046555160
9March'21LHR350465551605665
10March'21ISL155516056656170
11March'21ISL260566561706675
12
13MonthChannelStoreDay SaleUnits
14March'21KHI1Tuesday11
15March'21LHR2Wednesday50
16March'21ISL1Sunday70
17March'21KHI4Monday30
18March'21LHR3Tuesday46
Sheet1
Cell Formulas
RangeFormula
E14:E18E14=INDEX(INDEX($D$2:$J$11,1,MATCH(D14&"*",$D$1:$J$1,0)):INDEX($D$2:$J$11,10,MATCH(D14&"*",$D$1:$J$1,0)),MATCH(1,($B$2:$B$11=B14)*($C$2:$C$11=C14),0))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Another option
Excel Formula:
=SUMPRODUCT(($B$2:$B$11=B14)*($C$2:$C$11=C14)*(LEFT($D$1:$J$1,LEN(D14))=D14)*($D$2:$J$11))
 
Upvote 0
Another option
Excel Formula:
=SUMPRODUCT(($B$2:$B$11=B14)*($C$2:$C$11=C14)*(LEFT($D$1:$J$1,LEN(D14))=D14)*($D$2:$J$11))
Thanx Fluff, its work perfectly fine, one thing more how can i write it in vba code for future purposes.
 
Upvote 0
How about
VBA Code:
Sub Capricorn()
   Dim Ary As Variant
   Dim Dic As Object
   Dim r As Long, c As Long
   Dim Txt As String
   Dim Cl As Range
   
   Set Dic = CreateObject("scripting.dictionary")
   Ary = Range("A1").CurrentRegion.Value2
   
   For r = 2 To UBound(Ary)
      Txt = Ary(r, 2) & "|" & Ary(r, 3)
      If Not Dic.exists(Txt) Then Dic.Add Txt, CreateObject("scripting.dictionary")
      For c = 4 To UBound(Ary, 2)
         Dic(Txt)(Ary(1, c)) = Dic(Txt)(Ary(1, c)) + Ary(r, c)
      Next c
   Next r
   
   For Each Cl In Range("E14:E" & Range("B" & Rows.Count).End(xlUp).Row)
      Cl.Value = Dic(Cl.Offset(, -3).Value & "|" & Cl.Offset(, -2).Value)(Cl.Offset(, -1).Value & " (Sale)")
   Next Cl
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub Capricorn()
   Dim Ary As Variant
   Dim Dic As Object
   Dim r As Long, c As Long
   Dim Txt As String
   Dim Cl As Range
  
   Set Dic = CreateObject("scripting.dictionary")
   Ary = Range("A1").CurrentRegion.Value2
  
   For r = 2 To UBound(Ary)
      Txt = Ary(r, 2) & "|" & Ary(r, 3)
      If Not Dic.exists(Txt) Then Dic.Add Txt, CreateObject("scripting.dictionary")
      For c = 4 To UBound(Ary, 2)
         Dic(Txt)(Ary(1, c)) = Dic(Txt)(Ary(1, c)) + Ary(r, c)
      Next c
   Next r
  
   For Each Cl In Range("E14:E" & Range("B" & Rows.Count).End(xlUp).Row)
      Cl.Value = Dic(Cl.Offset(, -3).Value & "|" & Cl.Offset(, -2).Value)(Cl.Offset(, -1).Value & " (Sale)")
   Next Cl
End Sub
You are great man, Thanx a lot, God bless you
 
Upvote 0
You are great man, Thanx a lot, God bless you
Dear I m facing a little issue in it, actually I have two files one file is "Stores Raw Data" and other is "Final Sales Data Row-wise", I want those sales unit in Final Sales Data Row-wise sheet1's last available column, would it b possible, thanx a lot for help
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,958
Members
449,200
Latest member
indiansth

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