Hello,

I am very new to using vba in excel and i am facing this problem to
exporting specific excel cells into certain field in an access table.

I have around twenty tabs in a single spreadsheet, all containing same
format but different data.


here's the code:

Sub SelectSheets1()
    Dim mySheet As Object
    For Each mySheet In Sheets
        With mySheet
            If .Visible = True Then .Select Replace:=True
            Dim cn As ADODB.Connection, rs As ADODB.Recordset
            Set cn = New ADODB.Connection
            cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
            "Data Source=P:\Finance\FPandA\Tomato\Repack Costing-Julio
\Repackdata.mdb;"
            Set rs = New ADODB.Recordset
            rs.Open "Repackdata", cn, adOpenKeyset, adLockOptimistic,
adCmdTable
                 With rs
                    .AddNew
                    .Fields("F1") = Range("I1").Value
                    .Update
                 End With
            rs.Close
            Set rs = Nothing
            cn.Close
            Set cn = Nothing
        End With

    Next
End Sub

Any help, is appreciated.

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
Like our page on facebook , Just follow below link
http://www.facebook.com/discussexcel

Reply via email to