
Dim I As Long, X As Integer
Sub Scrivi_su_più_Fogli()
File_Inp = "c:PROVA.TXT"
Open File_Inp For Input As #1
I = 0
X = 1
Sheets(X).Select
Cells.ClearContents
Do Until EOF(1)
I = I + 1
Line Input #1, Dati
' ActiveSheet.Cells(I, 1) = "---" & Dati & "+++"
ActiveSheet.Cells(I, 1) = Dati
If I >= 65535 Then ‘ QUI metti il valore che ti necessita, io ho utilizzato il valore di excel 2003 meno “1”
X = X + 1
Sheets(X).Select
On Error GoTo Inserisci_foglio
Cells.ClearContents
I = 0
End If
Loop
Close
MsgBox "Eleborazione Terminata"
Exit Sub
Inserisci_foglio:
Sheets.Add
Sheets(X - 1).Select
Sheets(X - 1).Move After:=Sheets(X)
Resume Next
End Sub
|
Dim I As Long, X As Integer
Sub Scrivi_su_più_File()
File_Iniziale = ActiveWorkbook.Name
File_Inp = "c:appunti1.txt"
Open File_Inp For Input As #1
I = 0
X = 1
Workbooks.Add
Application.ScreenUpdating = False
Do Until EOF(1)
I = I + 1
Line Input #1, Dati
ActiveSheet.Cells(I, 1) = Dati
If I >= 5 Then
ActiveWorkbook.SaveAs Filename:= _
"File_Salvato_" & Format(X, "000") & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
X = X + 1
ActiveWorkbook.Close
Workbooks.Add
[A1].Select
I = 0
End If
Loop
ActiveWorkbook.SaveAs Filename:= _
"File_Salvato_" & Format(X, "000") & ".xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Application.ScreenUpdating = True
Close
MsgBox "Eleborazione Terminata, sono stati salvati '" & X & "' File"
End Sub
|
