VBA code to filter data from cell and save as filtered data into a new workbook with specific file name based on cell value

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
200
Office Version
  1. 2013
Platform
  1. Windows
There are 2 tabs in this file. 1 - Mapping sheet which has filter data column and file name column. 2nd tab is "Required data" where raw data is stored.

Objective - create a macro to filter data and save as into a new workbook with file name based on cell value.

step 1 - go to mapping sheet column F "filter key column" and copy single cell value f2 i.e. "cognizant" and filter this cell value in tab "required data" column A. (need a loop function here as data count is dynamic)
step 2 - now from "required data" tab, we want to copy the filtered data (from column B1 onwards and visible cells only since we have a column grouping) into a new workbook and the file name of the new workbook should be based on cell value (mapping sheet column G, cell G2) (need a loop function here as data count is dynamic)
step 3 - file can be saved on desktop in a new folder which can be named as "Output".

you can also refer the below file images for your further action. Thanks a lot in advance and please let me know if you have any questions!!

Mapping sheet

VAM.xlsb
ABCDEFG
1Do Not DeleteScopeDO Not DeleteFilter KeyFile Name
2xxxYaaaaCognizantChina
3xxxNvvvvBooking HoldingJapan
4xxxxxxYbbbbBerry GlobalAus
5xxxxxxNhhhhMc DonalsNZ
6jjjjAmerican TouristerKR
Mapping


sheet 2 "Required data"

VAM.xlsb
ABCEFIMPRTWXYABAC
1Filter KeyRefUPLegal EntitySinAC NoLeadSales PCoverageChannelProductThreshCurrencyDateTerm
2Cognizant1CognizantAaassdd1211123ABCzzaaaaddddeeeecsfdfdf858/4/2022sdfs
3Booking Holding2Booking Holdingddsvgdsvdsfddds20vgdsvdsfsf
4Berry Global3Berry Globalxssddfdsfsxxxd11dfdfsf
5Mc Donals4Mc Donalscdddafaddfadcccd21dafadssfs
6American Tourister5American Touristerfddsfaassffffd15sfasfsf
2 Required Data



output file save as into a new workbook

VAM.xlsb
ABCDEFGHIJKLMN
1RefUPLegal EntitySinAC NoLeadSales PCoverageChannelProductThreshCurrencyDateTerm
21CognizantAaassdd1211123ABCzzaaaaddddeeeecsfdfdf858/4/2022sdfs
China
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,224,814
Messages
6,181,125
Members
453,021
Latest member
Justyna P

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