In VBA Excel transferring data from Excel to Access.
I want to know how to increment the [ID] for each value of the range. [ID] is the Primary Key.
I have tried "NULL".
I have tried adding "n=n+1" after the "for each" and "thisSQL = "INSERT INTO... VALUES (" & n & ",..."
Code
For Each value In Range("D5:D" & Cells(Rows.Count, "D").End(xlUp).Row) accDateSub = Cells(value.Row, 1) accDescSub = Cells(value.Row, 2) accSub = Cells(value.Row, 3) thisSQL = "INSERT INTO [Table1] ([ID], [Date], [Desc], [Data]) VALUES ("[U]What goes here?[/U] ", #" & Format(CDate(accDate), "MM/DD/YY") & "#, '" & accDesc & "', " & accData & ");" conn.Execute CommandText:=thisSQLNext