我正在尝试创建一个过滤器,用于过滤动态数组收集的值。以下代码适用于此,但在过滤时也包含空值。如果我添加第二个cirteria,这似乎也不起作用。任何帮助将不胜感激。
Sub AppToServerFilter()
Dim Apps() As String, size As Integer, i As Integer
'creates an array and fills it with values in the checksheet
With Sheets("CheckSheet")
Sheets("CheckSheet").Activate
size = WorksheetFunction.CountA(Worksheets("CheckSheet").Columns(1))
ReDim Apps(size)
For i = 1 To size
Apps(i) = Cells(i, 1).Value
Next i
End With
'Commented out the array print
'For i = LBound(Apps) To UBound(Apps)
'txt = txt & Apps(i) & vbCrLf
'Next i
'MsgBox txt
'filters for all values in the array created above
Worksheets("App-to-Server").Select
'Range("A6").AutoFilter
'Range("A6").AutoFilter Field:=8, Criteria1:=Apps(), Operator:=xlFilterValues
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=8, Criteria1:=Apps(), Operator:=xlFilterValues
End Sub
答案 0 :(得分:1)
Apps() is a zero based array. Make the following changes:
cur_dir = sys.argv[1] if len(sys.argv) > 1 else '.'
with open(cur_dir + '/Concatenated.csv', 'w+') as outfile:
try:
with open(cur_dir + '/MatrixHeader.csv') as headerfile:
for line in headerfile:
outfile.write(line + '\n')
except:
print 'No Header File'