Macro to extract data based on specific criteria

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
197
Office Version
  1. 2013
Platform
  1. Windows

Book1
ABCDEFGHIJKLM
1Selection CriteriaRaw Data
2RegionAPACDeal IDClientSegmentProductRegionCountryRevenueStageDateBanker
3CountryAll6678KonamiEnergyCCAPACChina$50Closed1-Mar-18Sam
4ClientAll1234567JCBMidwestFXAPACIndia$100Closed3-Mar-18Arsene
5StageClosed1234567JCBMidwestCCAPACIndia$75Closed2-Mar-18Jose
6BankerAll6678KonamiEnergyFXAPACIndia$50Closed1-Mar-18Arsene
7SegmentAll
8ProductAll
9Top X2
top X





Book1
BCDEFGHIJKL
1Final Output
2#ClientSegmentProductBankerRegionCountryStageDateDeal IDRevenue
3JCBMidwestFX; CCArsene; JoseAPACIndiaClosed3-Mar-181234567$175
41JCB Total$175
5KonamiEnergyFX; CCArsene; samAPACIndia;ChinaClosed1-Mar-186678$100
62Konami Total$100
7Grand Total$275
8
Output




Sheet Top X - A2:B9 is the selection criteria. D2:M12 is the Raw data. Sheet Output B1 : B7 is the final output
I know this can be done by formulas and pivot but I need a macro. Can someone please provide a code for below criteria?
1 - arrange the columns as per row 2 order
2 - column B should have sr. no.
3 - Column C & L should have subtotals
4 - Product to be concatenated based on Deal ID (refer cell E3). For ex Client JCB have 2 products i.e. FX & CC (refer raw data)
5 - Banker to be concatenated based on Deal ID (refer column F) For ex Client JCB have 2 Bankers i.e. Arsene & Jose
6 - Country to be concatenated based on deal ID (refer column H) for ex Client Konami appears in 2 countries China & India.
7 - If product appear multiple time then the code should take only distinct value. For example if 1 deal id have FX, FX, CC then final output should be (FX; CC) and not (FX; FX; CC). Similar logic is applicable for banker and Country
8 - Sort order 1 - Revenue (Highest to Lowest) 2 - Date (oldest to newest)
9 - data should change and retrive the result based on below selection criteria. For Example - here I have selected Region = APAC, Stage = Closed and Top = 2 (based on Revenue)


Book1
CD
24RegionAPAC
25CountryAll
26ClientAll
27StageClosed
28BankerAll
29SegmentAll
30ProductAll
31Top X2
Output
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
hello, please can anyone look into this? let me know if this is possible or not.
 
Upvote 0

Forum statistics

Threads
1,216,092
Messages
6,128,782
Members
449,468
Latest member
AGreen17

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