Advertisement
Danila_lipatov

for me_cont

Nov 3rd, 2022 (edited)
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Get_Formula(ce As Range) As String
  2.     If ce.HasFormula Then
  3.         Get_Formula = CStr(ce.FormulaLocal)
  4.     Else
  5.         Get_Formula = "Not formula exist!"
  6.     End If
  7. End Function
  8.  
  9. Function Sh_Exist(wb As Workbook, sName As String) As Boolean
  10.     Dim wsSh As Worksheet
  11.     On Error Resume Next
  12.     Set wsSh = wb.Sheets(sName)
  13.     Sh_Exist = Not wsSh Is Nothing
  14. End Function
  15.  
  16. Sub ShowGetOpenDialod()
  17.     Dim avFiles
  18.     checkpath = ""
  19.     Application.EnableEvents = False
  20.     Application.ScreenUpdating = False
  21.    
  22.     If Right(checkpath, 1) <> "\" Then
  23.        checkpath = checkpath & "\"
  24.     End If
  25.    
  26.      
  27.     checkname = Dir(checkpath & "test.xlsx")
  28.    
  29.     Sheet_work = "output"
  30.    
  31.    
  32.     k = 1
  33.     ' Excel(xls,xlsx,xlsm,xlsb)
  34.    avFiles = Application.GetOpenFilename _
  35.                 ("Excel files(*.xlsx*),*.xlsx*", 1, "Choose Excel", , True)
  36.     If VarType(avFiles) = vbBoolean Then
  37.         Exit Sub
  38.     End If
  39.     'avFiles - string format
  40.    'MsgBox "Choosen file: '" & avFiles & "'", vbInformation, "www.excel-vba.ru"
  41.    For Each x In avFiles
  42.         Workbooks.Open Filename:=(x)
  43.        
  44.         Workbooks(checkname).Sheets(Sheet_work).Cells(k, 1).Value = Dir(x)
  45.        
  46.         Workbooks(checkname).Sheets(Sheet_work).Cells(k, 2) = (Get_Formula(Workbooks(x).Sheets("Validation").Range("E3")))
  47.        
  48.         Workbooks(checkname).Sheets(Sheet_work).Cells(k, 3) = (Get_Formula(Workbooks(x).Sheets("Validation").Range("E4")))
  49.        
  50.         Workbooks(checkname).Sheets(Sheet_work).Cells(k, 4) = (Get_Formula(Workbooks(x).Sheets("Validation").Range("E5")))
  51.    
  52.         Workbooks(Dir(x)).Close
  53.        
  54.         k = k + 1
  55.     Next
  56.    
  57. End Sub
  58.  
  59.  
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement