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:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Tab Name[/TD]
[TD]File Name[/TD]
[/TR]
[TR]
[TD]Bananas_For_Sale[/TD]
[TD]Bananas.sal[/TD]
[/TR]
[TR]
[TD]Apples_For_Sale_No[/TD]
[TD]Apples_for_sale_November.sal[/TD]
[/TR]
</tbody>[/TABLE]

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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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