Hi Expert,

I have macro worksheet which import data from SQL based on active sheet Range("B3"). It's working fine. But i want to add two more condition start date Range("C3") and end date Range("D3").
My English is poor but i hope you guys will understand.

Sub GetSMSSalesdata()
Dim sdate, edate As Variant

Application.ScreenUpdating = False
connectDB

Sheets("SMSSalesdata").Select
ActiveSheet.Unprotect Password:="12345"
Range("B6:H10000").ClearContents
Range("B6:H10000").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
Selection.Font.Bold = False
End With
Sheets("SMSSalesdata").Select
Pname = ActiveSheet.Range("B3").Value
sdate = ActiveSheet.Range("C3").Value
edate = ActiveSheet.Range("D3").Value
Range("B6").Select

Set rs = New ADODB.Recordset

strsql = "exec GetReport '" & Pname & "' ," & "'dnvsls'"
rs.Open strsql, conn, adOpenKeyset, adLockBatchOptimistic

'If rs.RecordCount > 0 Then
ActiveCell.CopyFromRecordset rs
'End If


MsgBox ("Report Refreshed Successfully")

ActiveSheet.Protect Password:="12345"
End Sub