VBA to delete lines in .txt with multiple specific string.

BryanAnnang

New Member
Joined
Nov 17, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi I'm new here but I have been browsing here from long time.. I have a new project that needs to alter data on .txt file using excel VBA.

Lets say I have the below Line in .txt and ill be putting the string that I wanted to delete from .txt file in excel range. All lines in .txt file that contains these string should be deleted in .txt file. See below sample... Someone's help would be highly appreciated.

TXT file Excel Range to Delete TXT file output should be:

Sampletext1 ,1111 ,2222 Sampletext1 Sampletext3 ,1111 ,2222
Sampletext2 ,1111 ,2222 Sampletext2 Sampletext4 ,1111 ,2222
Sampletext3 ,1111 ,2222 Sampletext5
Sampletext4 ,1111 ,2222
Sampletext5 ,1111 ,2222

Bryan
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
TXT file:
Sampletext1 ,1111 ,2222
Sampletext2 ,1111 ,2222
Sampletext3 ,1111 ,2222
Sampletext4 ,1111 ,2222
Sampletext5 ,1111 ,2222

Excel Range to (String to Delete in TXT):
Sampletext1
Sampletext5
Sampletext2

TXT file output should be:
Sampletext3 ,1111 ,2222
Sampletext4 ,1111 ,2222
 
Upvote 0

Forum statistics

Threads
1,214,889
Messages
6,122,097
Members
449,065
Latest member
albertocarrillom

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