Secondo me questo e' lo stesso quesito che hai posto nell'altra discussione...
Comunque, per farla semplice, prova con:
- Codice: Seleziona tutto
Sub ppp()
Dim tdWs As Worksheet, mioFile As String
Set tdWs = Worksheets("output")
Dim K As Long, nextI As Long
'
Sheets("Foglio1").Select '<<< Il numero o nome del foglio
nextI = tdWs.Cells(tdWs.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
For K = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Cells(K, 1).Resize(1, 13).Copy tdWs.Cells(nextI, 1): nextI = nextI + 1
tdWs.Cells(nextI - 1, "F").Resize(1, 6).ClearContents
If Cells(K, "G") <> "" Then
Cells(K, 1).Resize(1, 13).Copy tdWs.Cells(nextI, 1): nextI = nextI + 1
tdWs.Cells(nextI - 1, "C").Resize(1, 3).Value = tdWs.Cells(nextI - 1, "F").Resize(1, 3).Value
tdWs.Cells(nextI - 1, "F").Resize(1, 6).ClearContents
End If
If Cells(K, "J") <> "" Then
Cells(K, 1).Resize(1, 13).Copy tdWs.Cells(nextI, 1): nextI = nextI + 1
tdWs.Cells(nextI - 1, "C").Resize(1, 3).Value = tdWs.Cells(nextI - 1, "I").Resize(1, 3).Value
tdWs.Cells(nextI - 1, "F").Resize(1, 6).ClearContents
End If
Next K
End Sub
Ciao