I try to copy data from table tblkasir
to tbldafta
using a button. But when I click the button the button my Excel is not responding and keeps adding the data until the last row.
Here the script of the button.
Private Sub cmdSimpan_Click()
SimpanNota
SimpanDafta
End Sub
Sub SimpanNota()
ActiveWorkbook.Sheets("kasir").Activate
Sheets("kasir").Range("Q4").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Value = Sheets("kasir").Range("N3").Value
End Sub
Sub SimpanDafta() 'this is the script that keep looping
ActiveWorkbook.Sheets("daftar transaksi").Activate
Sheets("daftar transaksi").Range("tbldafta[[nomor transaksi]:[jumlah]]").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
Sheets("daftar transaksi").Select
Sheets("kasir").Range("tblkasir[[nomor transaksi]:[jumlah]]").Copy Destination:=Sheets("daftar transaksi").Range(Selection, Selection.End(xlDown))
ActiveCell.Offset(1, 1).Range("C9") = Sheets("daftar transaksi").Range(Selection, Selection.End(xlDown))
Application.CutCopyMode = False
Sheets("kasir").Range("tblkasir[[nomor transaksi]:[jumlah]]").ClearContents
Sheets("kasir").Range("K4").ClearContents
End Sub
please help.