Results 1 to 2 of 2

Deleting values / lines from a single text file code changing to deleting from multiple fi

Threaded View

  1. #1
    Registered User
    Join Date
    01-09-2015
    Location
    LONDON
    MS-Off Ver
    2010
    Posts
    23

    Deleting values / lines from a single text file code changing to deleting from multiple fi

    I've got the following code which allows me to delete lines from a text file based on a input value i.e. a date 001:2003 etc etc The code works fine for one file at a time , but how could I modify it so as it looks at all files in a directory and modifies them accordingly?


    Dim inz As String
    Dim outz As String
    Dim remove As String
    Dim remove2 As String
    
    
    inz = Me.txtXLFIle
    outz = Me.txtXLFIle
    remove = Me.Text7
    'remove2 = Me.Text9
    
    
    Const ForReading = 1
    Const ForWriting = 2
    
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(inz, ForReading)
    
    
    Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    If InStr(strLine, remove) = 0 Then
    strNewContents = strNewContents & strLine & vbCrLf
    
    End If
    Loop
    
    
    objFile.Close
    
    
    Set objFile = objFSO.OpenTextFile(outz, ForWriting)
    objFile.Write strNewContents
    
    
    objFile.Close
    
    
    
    
    End Sub
    Last edited by FDibbins; 10-09-2015 at 09:19 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Deleting one wing of twin text within a single Cell
    By ghoneim in forum Excel General
    Replies: 2
    Last Post: 04-16-2013, 11:56 AM
  2. Changing dates to text using VBA & deleting a column
    By BarnardSteyn in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-16-2012, 09:38 AM
  3. Code for Inserting & Deleting lines
    By markvdh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-05-2011, 09:10 AM
  4. VBA Code for deleting contents of multiple lines
    By modest_16081982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2007, 03:31 AM
  5. Deleting text file lines
    By RomanR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2006, 10:45 AM
  6. [SOLVED] Deleting multiple lines
    By tammytlc in forum Excel General
    Replies: 1
    Last Post: 10-03-2005, 07:05 PM
  7. Deleting/Changing values
    By teresa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-23-2005, 02:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1