help anyone ?
Printable View
help anyone ?
run a loop in excel that passes the data into a multi-dimension array.
then insert the data into Access using sql
hope this helps
i c star :eek: :confused: heee got any examples?Quote:
Originally posted by beasty1711
run a loop in excel that passes the data into a multi-dimension array.
then insert the data into Access using sql
hope this helps
dim objexcel as new excel.application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open ("c:\temp.xls")
With objExcel.Worksheets(1)
For r = 1 To .UsedRange.Rows.Count
name = .Cells(r, 1).Value
address = .cells(r,2).value
xsql = "INSERT INTO table1 VALUES ('" & name & "','" &
address & "')"
adodb.execute xsql
next
note : adodb is your database connection
wat if i dont know the columns name at the first place or i dont know how many columns are thereQuote:
Originally posted by tpiano
dim objexcel as new excel.application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open ("c:\temp.xls")
With objExcel.Worksheets(1)
For r = 1 To .UsedRange.Rows.Count
name = .Cells(r, 1).Value
address = .cells(r,2).value
xsql = "INSERT INTO table1 VALUES ('" & name & "','" &
address & "')"
adodb.execute xsql
next
note : adodb is your database connection
with this approach it is assume the corresponding col. to take matching with your table columns. with the number of columns you can determine by usedrange.cols.count.
another simpler approached is to link the excel files in your database either in design time or in runtime..
i can help you more if you clarify further what your requirement is ?
i need to create a table in access and transfer my data in my worksheets over in this case i have about 8 columns to transfer from my worksheets and i need 2 columns to be defaulted to 0 which means i have 10 columns all in all. one more thing i realise when i run this coding it does transfer but the excel application appear to be still running in the background. is it my system problem or?..:oQuote:
Originally posted by tpiano
with this approach it is assume the corresponding col. to take matching with your table columns. with the number of columns you can determine by usedrange.cols.count.
another simpler approached is to link the excel files in your database either in design time or in runtime..
i can help you more if you clarify further what your requirement is ?
add this lines to close the excel application in the background
objexcel.activeworkbook.close
set objexcel = nothing
shucks.. how do i link to the database using ADO
in DAO
set db = opendatabase("c:\test.mdb")
sql = "select * from test table"
set rs= db.openrecordset(sql,dbopendynaset)
text1.text = rs!name
erm how do we code using ADO?
:confused: :confused: