Sub kumpulkan()
FileTerpilih = Application.GetOpenFilename _
("XLSX File (*.xlsx),*.xlsx", Title:="Open file", MultiSelect:=True)
If VarType(FileTerpilih) = vbBoolean Then
Exit Sub
End If
NamaFileUtama = ActiveWorkbook.Name
JumlahFile = UBound(FileTerpilih)
Application.DisplayAlerts = False
For i = 1 To JumlahFile
Workbooks.Open FileTerpilih(i)
With ActiveWorkbook.Worksheets("sheet1")
BarisTerakhirFilePilihan = .Cells(.Rows.Count, 1).End(xlUp).Row
BarisTerakhirFileUtama = Workbooks(NamaFileUtama).Worksheets("Sheet1") _
.Cells(Workbooks(NamaFileUtama).Worksheets("sheet1").Rows.Count, 1).End(xlUp).Row
.Range("A6:M" & BarisTerakhirFilePilihan).Copy _
Destination:=Workbooks(NamaFileUtama).Worksheets("Sheet1").Range("A" & BarisTerakhirFileUtama + 1)
End With
ActiveWorkbook.Close
Next i
Application.DisplayAlerts = True
End Sub
Sub RESET()
Sheets("Sheet1").Range("a3:m1000").Clear
End Sub
No comments:
Post a Comment