I am getting data type mismatch in criteria error in this code..
please help
Application.ScreenUpdating = False
Application.ScreenUpdating = False
graph3.Unprotect
Dim winchoice, tierchoice, originalchoice, reg_terr_choice, decilechoice As String
Graph_data.Range("graph_r1").Clear
If terr_master_list.Range("pivotfield_calledon").Value = "All" Then
winchoice = "1, 2"
Else
winchoice = terr_master_list.Range("pivotfield_calledon").Value
End If
If terr_master_list.Range("pivotfield_decile").Value = "All" Then
decilechoice = "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
Else
decilechoice = terr_master_list.Range("pivotfield_decile").Value
End If
If terr_master_list.Range("pivotfield_original").Value = "All" Then
originalchoice = "'Y', 'N'"
Else
originalchoice = " '" & terr_master_list.Range("pivotfield_original").Value & "' "
End If
If terr_master_list.Range("tierchoice").Value = "All" Then
tierchoice = "1, 2"
Else
tierchoice = terr_master_list.Range("tierchoice").Value
End If
If terr_master_list.Range("pivotfield_Region").Value = "All" Then
reg_terr_choice = "5410, 5420, 5430"
ElseIf terr_master_list.Range("graph3_1_5choice").Value <= 4 Then
reg_terr_choice = terr_master_list.Range("pivotfield_Region").Value
Else
reg_terr_choice = " '" & terr_master_list.Range("pivotfield_Region").Value & "' "
End If
Data_Range = GetDataRange_Query([Graph_data], Range(Range(Range("graph_dataStart"), Range("graph_dataStart").Offset(5000, 0).End(xlUp)), Range(Range("graph_dataStart"), Range("graph_dataStart").End(xlToRight))))
If terr_master_list.Range("pivotfield_Region").Value = "All" Or terr_master_list.Range("pivotfield_Region").Value = 5410 Or terr_master_list.Range("pivotfield_Region").Value = 5420 Or terr_master_list.Range("pivotfield_Region").Value = 5430 Then
strsql = "Select * From " & Data_Range & " Where [Region_Code] in (" & reg_terr_choice & ") AND [Decile] in (" & decilechoice & ") AND [Win_Called_on] in (" & winchoice & ") AND [Account_Tier] in (" & tierchoice & ") AND [Original_Account] in (" & originalchoice & ");"
Else
strsql = "Select * From " & Data_Range & " Where [Territory_Code] in (" & reg_terr_choice & ") AND [Decile] in (" & decilechoice & ") AND [Win_Called_on] in (" & winchoice & ") AND [Account_Tier] in (" & tierchoice & ") AND [Original_Account] in (" & originalchoice & ");"
End If
PasteSQl strsql, [graph_strt]
graph3.Protect AllowSorting:=True, AllowFiltering:=True
Bookmarks