Excel VBA function with Recordset (Performance issue)
I have a database in SQL Server that I'm using to feed some financial reports in Excel. I'm using Recordsets through a custom Excel Function that uses arguments from Cells to build the SQL queries. Here is how the code looks: Public Function Test(arg1 As String, arg2 As String, arg3 As Integer, arg4 As Integer, arg5 As String) As Variant Dim oConnection As ADODB.Connection Set oConnection = New ADODB.Connection Dim oRecordset As ADODB.Recordset Set oRecordset = New ADODB.Recordset Dim strSQL As String strSQL = "SELECT SUM(BALANCE) as Total FROM Accounting WHERE ARGUMENT1 = " & Chr$(39) & arg1