Ciao IL CREM,
un txt? Prima avevi detto da una cartella di lavoro ad un'altra.
Per il txt un modo è questo:
Public Sub Test()
On Error GoTo ExtP
' ---------- PERSONALIZZARE ---------- >
'
Const cstrPath As String = "D:\Percorso\IL CREM"
Const cstrFilePfx As String = "TEST"
Const cstrFileExt As String = "TXT"
Const cstrWsh As String = "Foglio1"
Const cstrRng As String = "A1"
Const clngStep As Long = 300
Const clngCols As Long = 3
'
' ---------- PERSONALIZZARE ---------- <
Dim wbk As Excel.Workbook
Dim wsh As Excel.Worksheet
Dim rng As Excel.Range
Dim lngRow As Long
Dim lngOffset As Long
Dim avntRng As Variant
Dim intSfx As Integer
Dim strFullname As String
Dim ff As Integer
Dim intDim1 As Integer
Dim intDim2 As Integer
Dim strRow As String
Set wbk = Application.ThisWorkbook
Set wsh = wbk.Worksheets(cstrWsh)
Set rng = wsh.Range(cstrRng)
With wsh
For lngRow = rng.Row - 1 To .Rows.Count - 1 Step clngStep
If IsEmpty(rng.Offset(lngOffset).Value) Then Exit For
avntRng = .Range(rng.Offset(lngOffset), _
rng.Offset(lngOffset + clngStep - 1) _
).Resize(, clngCols).Value
intSfx = intSfx + 1
strFullname = cstrPath & cstrFilePfx & _
CStr(intSfx) & "." & cstrFileExt
ff = FreeFile
Open strFullname For Output As #ff
For intDim1 = LBound(avntRng, 1) To UBound(avntRng, 1)
strRow = ""
For intDim2 = LBound(avntRng, 2) To UBound(avntRng, 2)
strRow = strRow & vbTab & avntRng(intDim1, intDim2)
Next
strRow = Mid$(strRow, 2)
Print #ff, strRow
Next
Close
lngOffset = lngOffset + clngStep
Next
End With
ExtP:
With Err
If .Number Then MsgBox .Description
End With
On Error Resume Next
Close
Set rng = Nothing
Set wsh = Nothing
Set wbk = Nothing
End Sub