Guest User

Untitled

a guest
Mar 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. Sub addToFreeze()
  2. x% = firstDataBaseString
  3. Do While Application.Workbooks(thisFileName).Worksheets("municipalities").Cells(x, 2) <> Empty
  4. y% = firstDataBaseString
  5. actMun$ = Application.Workbooks(thisFileName).Worksheets("municipalities").Cells(x, 2)
  6. Do While Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1) <> Empty
  7. actFile$ = TrimFormats(Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1)) & addedToMunicipal & ".xls"
  8. openWaN$ = ThisWorkbook.Path & Application.PathSeparator & actMun & Application.PathSeparator & actFile
  9. Dim fileHaveNum As Boolean
  10. fileHaveNum = HasNumber(Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1))
  11. If FileExists(openWaN) Then
  12. Dim openApp As Excel.Application
  13. Set openApp = New Excel.Application
  14. openApp.DisplayAlerts = False
  15. openApp.Visible = True
  16. openApp.ScreenUpdating = False
  17. Dim openBook As Workbook
  18. Set openBook = openApp.Workbooks.Open(openWaN)
  19. For Each ws In openBook.Worksheets
  20. ws.Unprotect Password:="P$n177"
  21. afName$ = TrimFormats(actFile)
  22. sName$ = ws.Name
  23. Workbooks(afName).Worksheets(sName).Activate
  24. If fileHaveNum Then
  25. Range("G4:G4").Select
  26. ActiveWindow.FreezePanes = True
  27. Else
  28. Range("G6:G6").Select
  29. ActiveWindow.FreezePanes = True
  30. End If
  31. ws.Protect Password:="P$n177"
  32. Next
  33. openBook.Close SaveChanges:=True
  34. openApp.ScreenUpdating = True
  35. openApp.Quit
  36. End If
  37. y = y + 1
  38. Loop
  39. x = x + 1
  40. Loop
  41.  
  42. End Sub
Add Comment
Please, Sign In to add comment