Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.
Sub DAOFromExcelToAccess() Dim strTableName As String strTableName = "tblSurvey" ' exports data from the active worksheet to a table in an Access database ' this procedure must be edited before use Dim db As Database, rs As Recordset, r As Long Set db = OpenDatabase("C:\Documents and Settings\bryan.chu\Desktop\Metrics\Survey.mdb") ' open the database Set rs = db.OpenRecordset(strTableName, dbOpenTable) ' get all records in a table Dim lngTotalRows As Long lngTotalRows = ShtSurveyData.Columns(1).SpecialCells(xlCellTypeConstants).Rows.Count - 1 Dim i As Long Dim strFieldNames() As String ReDim strFieldNames(1 To 6) strFieldNames(1) = "Product" strFieldNames(2) = "Group" strFieldNames(3) = "SubGroup" strFieldNames(4) = "Category" strFieldNames(5) = "BankID" strFieldNames(6) = "Volume" Dim n As Integer n = 1 With rs For i = 1 To lngTotalRows .AddNew ' create a new record For n = 1 To 6 .Fields(strFieldNames(n)) = ShtSurveyData.Cells(i + 1, n).Value ' add values to each field Next n .Update Next i End With rs.Close Set rs = Nothing db.Close Set db = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.