1.獲取當前路徑所有檔名
Function get_file_arr()
Dim file_arr(), i
i = 1
this_path = ThisWorkbook.Path '獲取當前工作簿所在路徑
file_list = Dir(this_path & "\" & "*.*") '獲取當前路徑下的所有檔案
Do While Len(file_list)
If file_list <> ThisWorkbook.Name Then
ReDim Preserve file_arr(1 To i)
file_arr(i) = this_path & "\" & file_list
i = i + 1
End If
file_list = Dir
Loop
End Function
2.陣列去重
Function arr_deduplication(arr)
Dim i
Set d = CreateObject("scripting.dictionary")
For Each i In arr
'Debug.Print i
If Not d.exists(i) Then d.Add i, ""
Next
arr_deduplication = d.keys
End Function
3.判斷sheet是否存在
判斷sheet是否存在,返回False或True
Function sheet_is_exist(sheet_name) As Boolean
Dim i As Integer
For i = 1 To Sheets.Count
If Sheets(i).Name = sheet_name Then
sheet_is_exist = True
Exit Function
End If
Next
sheet_is_exist = False
End Function
本作品採用《CC 協議》,轉載必須註明作者和本文連結