Hi
I have an issue with an access form I have created, which allows any csv file to be imported without any errors. The only issue is the csv file being imported, needs to have a field titled 'Ref' with auto populated numbers in the data before importing, which means I manually need to add this each time (I can't do this after importing, as this is required to keep the structure)
I've created a vb code in excel, which does this job for me successfully. However is there any way of running this vb code from access?
I know how to run a macro which is already saved in the excel file from access, but this needs to work with any csv file to import
Code:
Sub Ref()
'Inserts an auto number
Dim r As Range
Columns(1).Insert Shift:=xlToRight
For Each r In ActiveSheet.UsedRange.Rows
Cells(r.Row, 1) = r.Row
Next
Range("A1").Select
ActiveCell.FormulaR1C1 = "Ref"
End Sub
Thank you for your help