
Public Sub m()
Dim shModulo As Worksheet
Dim shRegistro As Worksheet
Dim lRiga As Long
Dim lng As Long
With ThisWorkbook
Set shModulo = .Worksheets("FATTURA")
Set shRegistro = .Worksheets("MOVIMENTI")
End With
With shRegistro
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B22").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B23").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B24").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B25").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B26").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B27").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B28").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B29").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B30").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B31").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B32").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B33").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B34").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B35").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B36").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B37").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B38").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B39").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B40").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B41").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B42").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B43").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B44").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B45").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B46").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B47").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B48").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B49").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B50").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B51").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B52").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B53").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B88").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B89").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B90").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B91").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B92").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B93").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B94").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B95").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B96").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B97").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B98").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B99").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B100").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B101").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B102").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B103").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B104").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B105").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B106").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B107").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B108").Value
End With
Set shModulo = Nothing
Set shRegistro = Nothing
End Sub |
Option Explicit
Sub copia()
Dim WB As Workbook
Dim Ws1 As Worksheet
Dim Percorso As String, nomeFile As String, Uriga As Long
Percorso = "D:106" '<=== QUI DIGITA IL TUO PERCORSO con la finale
Application.ScreenUpdating = False
Set Ws1 = ThisWorkbook.Worksheets("MOVIMENTI")
nomeFile = Dir(Percorso)
Do While nomeFile <> ""
If nomeFile <> ThisWorkbook.Name Then
Workbooks.Open (Percorso & "" & nomeFile)
Workbooks(nomeFile).Worksheets("FATTURA").Range("B22:B58").Copy
Uriga = Ws1.Range("H" & Rows.Count).End(xlUp).Row
Ws1.Range("H" & Uriga).PasteSpecial
Workbooks(nomeFile).Close False
End If
nomeFile = Dir
Loop
Application.ScreenUpdating = True
MsgBox "Fatto"
Set Ws1 = Nothing
End Sub |
Option Explicit
Dim file() As String
Private Sub btnPercorso_Click()
Dim F As FileDialog
Dim filename As String
Dim ContTot As Integer
With Me
.txtPercorso = ""
.lstFile.Clear
.txtTotfile = ""
Set F = Application.FileDialog(msoFileDialogFolderPicker)
If F.Show = False Then Exit Sub
.txtPercorso = F.SelectedItems(1)
filename = Dir(Me.txtPercorso & "*.xlsx", vbArchive Or vbHidden Or vbNormal Or vbReadOnly Or vbSystem)
Do Until filename = ""
ReDim Preserve file(ContTot)
.lstFile.AddItem Left(filename, Len(filename))
file(ContTot) = Left(filename, Len(filename))
ContTot = ContTot + 1
filename = Dir
Loop
.txtTotfile = ContTot
End With
End Sub
Private Sub btnCarica_Click()
Dim F As Variant, pathFile As String
Dim rng As Range
Dim ur As Long, righe As Long, wsdati
If Me.lstFile.ListCount = 0 Then
Call MsgBox("Non hai caricato nessun file excel." & vbCrLf & "" & vbCrLf & _
"Possono essere caricati soltanto i file con estensione .xlsx" _
, vbExclamation Or vbDefaultButton1, "Selezione_nulla")
Exit Sub
End If
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With wsMovimenti
.Activate
For Each F In file
ur = .Cells(Rows.Count, "H").End(xlUp).Row + 1
If .[h1] = "" Then ur = 1
pathFile = Me.txtPercorso & "" & F
Call read_dati(pathFile, ur)
Next
Unload Me
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "Dati caricati con successo"
End Sub
Function read_dati(filename As String, ur As Long) As Long
Dim app As New Excel.Application, wbk As Excel.Workbook
Dim foglio As Worksheet, righe As Integer
On Error Resume Next
Set wbk = app.Workbooks.Add(filename)
With wbk.Sheets("FATTURA")
.Range("b22:b53").Copy
Range("H" & ur).Select
ActiveSheet.Paste
wbk.Application.CutCopyMode = False
End With
On Error Resume Next
Set wbk = app.Workbooks.Add(filename)
With wbk.Sheets("FATTURA")
.Range("g22:g53").Copy
Range("J" & ur).Select
ActiveSheet.Paste
wbk.Application.CutCopyMode = False
End With
wbk.Close SaveChanges:=False
app.Quit
Set app = Nothing
End Function
|
Public Sub m()
Dim shModulo As Worksheet
Dim shRegistro As Worksheet
Dim lRiga As Long
Dim lng As Long
With ThisWorkbook
Set shModulo = .Worksheets("FATTURA")
Set shRegistro = .Worksheets("MOVIMENTI")
End With
With shRegistro
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B22").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B23").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B24").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B25").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B26").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B27").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B28").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B29").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B30").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B31").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B32").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B33").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B34").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B35").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B36").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B37").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B38").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B39").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B40").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B41").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B42").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B43").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B44").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B45").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B46").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B47").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B48").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B49").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B50").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B51").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B52").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B53").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B88").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B89").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B90").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B91").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B92").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B93").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B94").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B95").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B96").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B97").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B98").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B99").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B100").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B101").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B102").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B103").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B104").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B105").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B106").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B107").Value
IRiga = .Range("H" & .Rows.Count).End(xlUp).Row + 1
.Range("H" & IRiga).Value = shModulo.Range("B108").Value
End With
Set shModulo = Nothing
Set shRegistro = Nothing
End Sub |
