VBA 自定义常用函数 (备用) 
                                                    
                        
                    
                    
  
                    
                    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 Function2.数组去重
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 Function3.判断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 协议》,转载必须注明作者和本文链接
 
           Bgods 的个人博客
 Bgods 的个人博客
         
           
           关于 LearnKu
                关于 LearnKu
               
                     
                     
                     粤公网安备 44030502004330号
 粤公网安备 44030502004330号