processing multiple files at a time in excel vba

naveenraja16

New Member
Joined
Mar 3, 2016
Messages
10
Hi,
I have made a code for reading a txt file and delete a set of lines in that file and save it in another location. Can you help me out in modifying the code for reading multiple files present in a particular folder and then do the process on all files and save those files with the same name in a different folder .I have attached the code herewith.


Sub cleantext()
Dim lineOfText As String
Dim skipLines As Boolean
'Open files for writing
Open "C:\Users\INNAR1\Desktop\input_static_files\ebb_htr01h.UCBG" For Input As #1
Open "C:\Users\INNAR1\Desktop\output_static_files\ebb_htr01h.UCBG" For Output As #2




skipLine = False
Do Until EOF(1)
Line Input #1, lineOfText
If lineOfText = "dynamics" Then skipLines = True
If lineOfText = "end dynamics" Then skipLines = False
If Not skipLines And Not lineOfText = "end dynamics" Then Print #2, lineOfText
Loop
Close #1
Close #2
End Sub



Thanks in advance
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,217,367
Messages
6,136,148
Members
449,994
Latest member
Rocky Mountain High

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