I have the below code, but whenever I try to run the report by changing the start date and end date the Range("EmailReason").Select does not find or losses the query, ie. stored procedure. Also does keeps the old query when the data range changes from a higher range value to lower range value.
I have set the external date range properties to "Insert Cells for New Date,Delete Unused Cells". I have got other sheets set the same but they working fine.
Please need help.
Code:Sheets("Mazda ").Activate Range("A9").Select With Selection.QueryTable .CommandText = Array("exec rpt_mazdaEmailstats @startdate='" & startdate & "', @enddate='" & enddate & "'") .Refresh BackgroundQuery:=False End With Range("EmailReason").Select With Selection.QueryTable .CommandText = Array("exec rpt_mazdaEmailReason @startdate='" & startdate & "', @enddate='" & enddate & "'") .Refresh BackgroundQuery:=False End With




Reply With Quote