VBA Insert Into Query So I have some vba which utilises a loop to run multiple insert statements based on the values in a worksheet. However with a large amount of rows this becomes extremely slow, and was wondering if there was a quicker way of doing this, where perhaps I could bulk insert whole section at once. I have the table and fields created on the SQL end. The debugger points to the cnn.Execute uSQL being the issue. I am trying to write the user and computer name of who is accessing the sheet to SQL.
I am experiencing a problem with inserting records into a Excel file using ADO from a VBA program. The Excel file is not open when the program is running to insert the records. The sheet I am inserting to has a header row and 12 rows of data before the VBA program runs. Here are the details to reproduce:
1. Open the target Excel workbook and select rows 14-200 and delete the rows
2. Save and close the Excel workbook
3. Run the VBA program which inserts records into the Excel workbook
4. The VBA program sucessfully inserts the data but it inserts them starting at row 201. I want it to insert them starting at row 14.
So apparently somehow the Excel workbook has saved some kind of cursor position on the target sheet based on the delete that was done. How can I reposition the cursor in the sheet so that the records are inserted to the correct row?
The VBA program has a pre-processing routine that opens the Excel workbook and performs some cleanup and then saves the file back to the drive before the insert routine runs. I have tried positioning the cursor on the sheet by selecting row 14 before doing the save. That doesn't work.
Any advice on this would be appreciated.