VBA code for specific sheets and creating a file

omf_24

New Member
Joined
Oct 10, 2013
Messages
8
I'll start off with I haven't done VBA coding in a while. This is what I am trying to do.

I have a column with tab names, and I have a column with file names that I want created. I'll give an example:
Tab NameFile Name
Bananas_For_SaleBananas.sal
Apples_For_Sale_NoApples_for_sale_November.sal

<tbody>
</tbody>

So basically, I want the macro to go through each tab name, copy the contents and create a file based on the file name. For example, go to the Apples_For_Sale_No tab, and create a file name called Apples_for_sale_November.sal.

Now here's another tricky part, I was told to use CreateTextFile otherwise the program that feeds in these .sal files wont work properly. A coworker gave me this piece of code. My problem is that the "Output_Start" only looks at the first line in one tab, but I need it to look at each tab, take the first line and stop at the end, making it comma delimited. Anyone able to please help me?

Set tsOutput = fs.CreateTextFile(rPath & Range("Output_Name") & ".sal")
Set rnRecord = Range("Output_Start")


Do While rnRecord(1) <> ""
tsOutput.WriteLine VBA.Left(IdentifierRecord(rnRecord), Len(IdentifierRecord(rnRecord)) - Len(sDelimiter))
Set rnRecord = rnRecord.Offset(1)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,821
Messages
6,121,759
Members
449,048
Latest member
excelknuckles

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