S
Sunil Pradhan
I have 2 excel files namely Interface.xls & Tracker.xls.
I have used following code to update data from Interface to Tracker.
Public Sub interface2datadump()
Sheet1.Select
Dim cn As ADODB.Connection, RS As ADODB.Recordset, RS1 As ADODB.Recordset, r
As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\Tracker\tracker.xls;" & _
"Extended Properties=""Excel 8.0;"""
Set RS = New ADODB.Recordset
RS.Open "select * from [DATABASE$]", cn, adOpenKeyset, adLockOptimistic
r = 2
With RS
.AddNew
.Fields("Name") = Sheet1.Cells(1, 2).Value
.Fields("Emp ID") = Sheet1.Cells(2, 2).Value
.Fields("Phone") = Sheet1.Cells(3, 2).Value
.Update
End With
RS.Close
Set RS1 = Nothing
Set RS = Nothing
cn.Close
Set cn = Nothing
Sheet1.Cells(1, 2).Value = ""
Sheet1.Cells(2, 2).Value = ""
Sheet1.Cells(3, 2).Value = ""
End Sub
Is there any better way to do this? or can I update the data to tracker
without opening the tracker.xls except using ADODB as I have used above.
Also, I want to edit some data in Tracker & I want to use Inerface file to
edit & update & even delete the data in tracker.xls. Please help me to write
code to fetch the data from tracker, edit & update.
Thanks,
I have used following code to update data from Interface to Tracker.
Public Sub interface2datadump()
Sheet1.Select
Dim cn As ADODB.Connection, RS As ADODB.Recordset, RS1 As ADODB.Recordset, r
As Long
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\Tracker\tracker.xls;" & _
"Extended Properties=""Excel 8.0;"""
Set RS = New ADODB.Recordset
RS.Open "select * from [DATABASE$]", cn, adOpenKeyset, adLockOptimistic
r = 2
With RS
.AddNew
.Fields("Name") = Sheet1.Cells(1, 2).Value
.Fields("Emp ID") = Sheet1.Cells(2, 2).Value
.Fields("Phone") = Sheet1.Cells(3, 2).Value
.Update
End With
RS.Close
Set RS1 = Nothing
Set RS = Nothing
cn.Close
Set cn = Nothing
Sheet1.Cells(1, 2).Value = ""
Sheet1.Cells(2, 2).Value = ""
Sheet1.Cells(3, 2).Value = ""
End Sub
Is there any better way to do this? or can I update the data to tracker
without opening the tracker.xls except using ADODB as I have used above.
Also, I want to edit some data in Tracker & I want to use Inerface file to
edit & update & even delete the data in tracker.xls. Please help me to write
code to fetch the data from tracker, edit & update.
Thanks,