saya mau tanya lagi kali ini soal export data ke file excel.
Jadi gini di file excel itu terbagi atas beberapa sheet (sheet1, sheet2,
sheet3,.......) yang mana sheet-sheet tersebut sudah ada border &
line-nya, jadi proses ini hanya melempar data ke kolom tertentu. Yang
jadi pertanyaan adalah bila terdapat data < dari 18 data maka di export
ke sheet1 dan bila < 37 maka di masukkan ke shee1 sebanyak 18 data dan
sheet2 sebanyak 18 juga. Terus berlanjut seperti itu tergantung berapa
banyak data yang ada.
Saat ini saya bingung bagaimana memerintahkan bila ketemu terdapat data
sebanyak 36 maka di export ke sheet1 sebanyak 18 data dan sheet2
dilanjutkan data ke 19 s/d. 36.?
Untuk export datanya sendir saya menggunakan perintah:
Dim i1 As Integer
Dim Row, Col, F As Long
Dim XlApp1 As Excel.Application
Dim XlBook1 As Excel.Workbook
Set XlApp1 = CreateObject("Excel.Application")
Set XlBook1 = XlApp1.Workbooks.Open("C:\POS-Mei\Faktur.XLS")
Dim XlSheet1 As Excel.Worksheet
Dim XlSheet2 As Excel.Worksheet
Set XlSheet1 = XlBook1.Worksheets(1)
Set XlSheet2 = XlBook1.Worksheets(2)
If Data2.Recordset.RecordCount < 19 Then
For i1 = 8 To Data2.Recordset.RecordCount + 7
XlSheet1.Cells(1, 3) = "Tangerang, " & Format(Now, "dd mmmm yyyy")
XlSheet1.Cells(2, 2).Value = Text12.Text
XlSheet1.Cells(3, 2).Value = Text16.Text
XlSheet1.Cells(4, 2).Value = Text17.Text & " - " & Text18.Text & " " &
Text19.Text
XlSheet1.Cells(i1, 2).Value = Data2.Recordset!Nama
XlSheet1.Cells(i1, 1).Value = Data2.Recordset!Kuantitas & " " &
Data2.Recordset!Satuan
XlSheet1.Cells(i1, 3).Value = Data2.Recordset!Harga
XlSheet1.Cells(i1, 4).Value = Data2.Recordset!Discount
XlSheet1.Cells(i1, 5).Value = Data2.Recordset!Total
Data2.Recordset.MoveNext
Next i1
XlSheet1.Cells(26, 5) = Text21.Text
XlSheet1.Cells(27, 1) = "# " & Text20.Text & " #"
XlSheet1.Application.SaveWorkspace
XlSheet1.Application.Quit
Set XlSheet1 = Nothing
XlApp1.Application.Quit
Set XlApp1 = Nothing
Timer7.Interval = 50
Screen.MousePointer = vbDefault
ElseIf data2.recordset.recordcount < 37 Then
*****di baris ini saya agak bingung untuk memerintah penulisan data ke 1
s/d. data ke 18 di sheet1 dan data ke 19 s/d. data ke 36 di sheet2.
End If
Mohon bantuannya karena mendesak sekali.
Terima kasih sebelumnya saya ucapkan.
[Non-text portions of this message have been removed]