Selamat sore semuanya,
Mohon kiranya dapat di bantu kasus saya ini. Saya membuat sebuah database
sederhana, di mana ada satu workbook yang saya gunakan sebagai Table
master. dan satu lagi worbook excel yang saya gunakan untuk mengirimkan
data ke table master dengan menggunakan VBA.
Permasalahan nya adalah script yang saya pakai di bawah ini, terkadang
mengirimkan data dengan baik ke data row paling akhir dari sebuah table
master, tapi terkadang data tersebut malah menimpa data lain yang sudah ada
dengan row yang berbeda ( data yang masuk ke kolom2 nya sudah tepat hanya
saja row nya yang berbeda, seharus nya adalah konsisten di row data sesudah
row terakhir )
Script nya adalah sbb :
Private Sub Kirimdata_Click()
If TextBox1.Value = "" Or TextBox4.Value = "" Then
If MsgBox("Form is not complete. Please fill the data No and the amount
!", vbQuestion + vbYesNo) <> yes Then
Exit Sub
End If
End If
Dim rc As Long
Dim path As String
Dim wb As Workbook
Application.ScreenUpdating = False
path = "\\blabla\blabla\blabla\master.xlsm"
rc = ActiveSheet.UsedRange.Rows.Count
Workbooks.Open " \\blabla\blabla\blabla\master.xlsm "
Set wb = ActiveWorkbook
rc = ActiveSheet.UsedRange.Rows.Count
With Sheets(1).Range("A1")
...Offset(rc, 0).Value = Me.ListBox1.Value
...Offset(rc, 1).Value = Me.ListBox2.Value
...Offset(rc, 2).Value = Me.ListBox3.Value
...Offset(rc, 3).Value = Me.ListBox4.Value
...Offset(rc, 4).Value = Me.ListBox5.Value
...Offset(rc, 5).Value = Me.TextBox1.Value
...Offset(rc, 6).Value = Me.TextBox2.Value
...Offset(rc, 7).Value = Me.TextBox3.Value
...Offset(rc, 8).Value = Me.ListBox6.Value
...Offset(rc, 9).Value = Me.TextBox5.Value
...Offset(rc, 10).Value = Me.TextBox4.Value
...Offset(rc, 11).Value = Me.TextBox7.Value
...Offset(rc, 12).Value = Me.TextBox8.Value
...Offset(rc, 13).Value = Me.ListBox7.Value
...Offset(rc, 14).Value = Me.TextBox6.Value
End With
wb.Save
wb.Close
Application.ScreenUpdating = True
Unload Me
Inputdata.Show
End Sub
Terima kasih sekali lagi untuk bantuan nya