I'm trying to run below vba but unfortunately when i add the parameters range its not working (doing nothing without any errors), but if i used the code with simple select it work perfectly .. please help !
Dim HRCONN As ADODB.Connection
Dim HRDATA As ADODB.Recordset
Dim HRFIELD As ADODB.FIELD
Set HRCONN = New ADODB.Connection
Set HRDATA = New ADODB.Recordset
HRCONN.connectionstring = CONSTRSQL
HRCONN.Open
On Error GoTo closeconnection
With HRDATA
.ACTIVECONNECTION = HRCONN
.Source = "EXEC DBO.LATENCY_REPORT" & "'" & Range("M12").Value & "'" & "," & "'" & Range("M13").Value & "'" & "," & "'" & Range("B12").Value & "'"""
.locktype = adLockReadOnly
.cursortype = adopenforwardonly
.Open
End With
On Error GoTo closerecordset
Worksheets.Add
For Each HRFIELD In HRDATA.Fields
ActiveCell.Value = HRFIELD.Name
ActiveCell.Offset(0, 1).Select
Next HRFIELD
Range("A1").Select
Range("A2").CopyFromRecordset HRDATA
Range("A1").CurrentRegion.EntireColumn.AutoFit
On Error GoTo 0
closerecordset:
HRDATA.Close
closeconnection:
HRCONN.Close
End Sub