Dear all,
I'm trying to run this VBA code
which it works but when I open the excel file I get this error:
and when I click "Yes" I get this message:
I think it is something depending on the variable because If I change Dim MyValue As Date to Dim MyValue As Variant I get this error:
Any suggestion to solve this issue?
Thanks
I'm trying to run this VBA code
VBA Code:
Private Sub cmdCheck_Click()
Dim i As Long
Dim PRDFromCombo() As Variant
Dim Ord As Long
Dim MyArray() As Variant
Dim MyValue As Variant
Application.Cursor = xlWait
For i = 0 To (cboPRD.ListCount - 1)
If CDate(cboPRD.List(i)) <= CDate(cboPRD.Text) Then
Ord = Ord + 1
ReDim Preserve PRDFromCombo(1 To Ord)
PRDFromCombo(Ord) = Format(CDate(cboPRD.List(i)), "mm/dd/yyyy")
End If
Next i
ReDim MyArray(1 To UBound(PRDFromCombo) * 2)
For i = 1 To UBound(PRDFromCombo) * 2
If i Mod 2 = 0 Then
MyValue = PRDFromCombo(i / 2)
Else
MyValue = 2
End If
MyArray(i) = MyValue
Next i
ActiveWorkbook.Sheets("Details").ListObjects("Table_Query_from_AGSV2").Range.AutoFilter Field:=17, Operator:=xlFilterValues, Criteria2:=MyArray
Application.Cursor = xlDefault
End Sub
which it works but when I open the excel file I get this error:
and when I click "Yes" I get this message:
I think it is something depending on the variable because If I change Dim MyValue As Date to Dim MyValue As Variant I get this error:
Any suggestion to solve this issue?
Thanks