VBA Save File Based On Filtered Change In Range

GoHeels

New Member
Joined
May 14, 2008
Messages
27
Hello, I would like to preface this with many thanks for insight or VBA sharing to assist in resolving my issue.

Background, I am utilizing Excel PQ to import multiple files from a directory, scrub the files, and load the massaged results files into a single worksheet named “Data” and table named “tbl_Load".

Column header is in row 1 and moves from Column A – Column D . Column C (Store Number) contains a listing of locations that I would like to use in a VBA script to save each new instance into a new workbook, using the value from this filtered field in the filename.

Example (reduced for simplicity). Below Data would be post PQ import/refresh. What I would like to do is run a script that will save a new file containing all records at the unique store number level So, in this data set, we see rows 2:8 are associated with Store 1, rows 9:15 are associated with records from store 5 and row 16 is associated with records for store 50 (stores could have varying record numbers).

Capture.JPG


Desired output would be 3 new .csv files that will output to a directory: \\Share\Load\Import with the store number as worksheet name along with store name and date appended as the filename. So, using example above post script would generate 3 unique files:

Store_1_08212023.csv (would contain 8 rows of records including header)

Store_5_08212023.csv (would contain 8 rows of records including header)

Store_50_0821203.csv (would contain 2 rows of records including header)

Anyone have a script to share that could perform such actions? Thanks again for any assistance!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Will the Store Names always be consecutive like in the example?
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

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