tusconpapa
MIS
I need to create 50 individual(US States as CA, TX, NY)<br>files from one Master File (with state codes) in the least number of passes. Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Explicit
Private Sub cmStart_Click()
Dim sPath As String
Dim sRec As String
Dim sCurrSt As String
Dim iStFld As Integer
Dim iIn As Integer
Dim iOut As Integer
cmStart.Enabled = False
lbStat.Caption = "Running"
sPath = App.Path & "\"
iStFld = 5 'Char pos. of State
iIn = FreeFile(0)
Open sPath & "all.txt" For Input As #iIn
Do Until EOF(iIn)
Line Input #iIn, sRec
If Mid(sRec, iStFld, 2) <> sCurrSt Then
If sCurrSt <> "" Then
Close #iOut
End If
sCurrSt = Mid(sRec, iStFld, 2)
iOut = FreeFile(0)
Open sPath & sCurrSt & ".txt" For Output As #iOut
End If
Print #iOut, sRec
Loop
Close #iOut, #iIn
lbStat.Caption = "Complete!"
End Sub