Professional Documents
Culture Documents
Application.ScreenUpdating = False
If IsFileOpen("c:\book1.xlsx") Then
MsgBox "Maaf, file book1.xlsx sedang dibuka, silahkan tutup file terlebih dahulu.."
Exit Sub
End If
Workbooks.Open FileName:="c:\book1.xlsx"
With Worksheets("Sheet1")
BarisTerakhir = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To 3
.Cells(BarisTerakhir + 1, i).Value = Me.Cells(2, i).Value
Next i
End With
Workbooks("book1.xlsx").Save
Workbooks("book1.xlsx").Close
Application.ScreenUpdating = True
End Sub
6. Jangan lupa, copy function berikut dibawah commandbutton1 click event. Function
ini berfungsi untuk memeriksa, apakah file telah dibuka atau belum.
End Function