Nih ada sample ambil data dr excel masuk ke flexgrid. Tapi kayaknya model kolomnya beda dengan kasus mas jonatan. Kl Contoh ini, kolomnya horosintal, datanya yang vertikal. Sedangkan contoh data mas jonatan, kolomnya vertikal, datanya horisontal. Ini bisa langsung input ke database atau masuk ke flexgrid dulu untuk cek data, kl dah bener baru bikin looping insert ke database.
Silakan di modif aja. Semoga bermanfaat.
Dim x As Integer
Dim xlsApp As Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet
Set xlsApp = New Excel.Application
xlsApp.Visible = False
Set book = xlsApp.Workbooks.Open(App.Path & "\coba.xls")
Set sheet = book.Worksheets(1) 'Sheet 1
'Loop through cells to get data and modify data if you want to
For x = 1 To 600
t_nomor.Text = MSHFlexGrid1.ColSel
MSHFlexGrid1.TextMatrix(x, 1) = sheet.Cells(x, 1)
MSHFlexGrid1.TextMatrix(x, 2) = sheet.Cells(x, 2)
MSHFlexGrid1.TextMatrix(x, 3) = sheet.Cells(x, 3)
MSHFlexGrid1.TextMatrix(x, 4) = sheet.Cells(x, 4)
MSHFlexGrid1.TextMatrix(x, 5) = sheet.Cells(x, 5)
MSHFlexGrid1.TextMatrix(x, 6) = sheet.Cells(x, 6)
MSHFlexGrid1.TextMatrix(x, 7) = sheet.Cells(x, 7)
Next x
book.Close False 'Or True if you want to save changes
xlsApp.Quit
-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of Nuzwan Gufron
Sent: 18 Februari 2008 17:31
To: [email protected]
Subject: Re: [Programmer-VB] Ambil data dari excel
Pake VBA aja kan mudah?
Logiknya pake fungsi loop/find kata2 tsb, trus loop sepanjang kolom, kalo
ketemu simpan..beres to?
I'm happy to show you how..but try fist key ;) ?
Regards,
Nuzwan Gufron
On 2/18/08, Jonathan Oei Joeng <[EMAIL PROTECTED]> wrote:
Friends,
Apakah dengan VB kita bisa buat program untuk ambil data tertentu dari
sheet excel ?
Contohnya adalah sebagai berikut :
Data sebagai berikut :
trus saya mo ambil data assay, reagent lot, cal date/time ama calmV dan
slope saja.
Masalahnya ada 2,000 data lebih jadi tidak mungkin saya ambil satu-satu.
Apakah VB bisa melakukan hal spt itu ?
thanks,
jonathan
This communication may contain information that is legally proprietary,
confidential, or exempt from disclosure. If you are not the intended
recipient, please note that any dissemination, distribution, use or copying
of this communication is strictly prohibited. Anyone who receives this
message in error should notify the sender immediately by telephone
+62-21-52961529 or by return e-mail and delete it from his or her computer.
<<ATT00013.gif>>
