Forum Discussion

JoeCavasin's avatar
JoeCavasin
Brass Contributor
Aug 18, 2021

Macro to Split Excel into Multiple Files - update

Afternoon all,

 

Need a little help improving a build of a file splitting macro.  Currently it operates by sorting data I add to the "Template" tab by column A, then splitting lines with a common data element in column A to an new sheet.  It then saves the new file named the same as the value in column A.  Example of existing output is on "Report - Current" tab. 

 

Updates i'm hoping to tackle with example file attached.

1. Add rows to the top of the output files.  example of desired info on "Report - Desired" tab in attachment.  

  • Note C1 and C2 would need to be flexible and driven by data matching logic as described on the "report - desired" tab.
  • Note C3, C4 & C5 would be constant values.

2. only generate files for which a value exists in column A.  While the control tab may show up to 6 values as possible identifiers for column A, we may only have 3 unique identifiers on a given report.  The goal would be to only output 3 files. 

  • In the example file i've placed 4 lines for TIN 1, 2 lines for TIN 2, and 3 lines for TIN 3.  
  • Ideally the desired output would be one file with four lines for TIN 1, 1 file with 2 lines for TIN 2, and one file with 3 lines for TIN 3.

3. Update the logic for naming the output of the file based on the formatting in Control Tab, cell E2.

 

I've attempted to build some concatenation for file naming into the VBA, but removed it when it failed after several attempts.  I however am nowhere near strong enough with VBA to do the other tweaks - new rows and output limitations for non-represented TIN's.  Any assistance is appreciated!

Thanks as always!

 

 

 

Joe

 

 

No RepliesBe the first to reply

Resources