Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub addToFreeze()
- x% = firstDataBaseString
- Do While Application.Workbooks(thisFileName).Worksheets("municipalities").Cells(x, 2) <> Empty
- y% = firstDataBaseString
- actMun$ = Application.Workbooks(thisFileName).Worksheets("municipalities").Cells(x, 2)
- Do While Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1) <> Empty
- actFile$ = TrimFormats(Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1)) & addedToMunicipal & ".xls"
- openWaN$ = ThisWorkbook.Path & Application.PathSeparator & actMun & Application.PathSeparator & actFile
- Dim fileHaveNum As Boolean
- fileHaveNum = HasNumber(Application.Workbooks(thisFileName).Worksheets("FilesList").Cells(y, 1))
- If FileExists(openWaN) Then
- Dim openApp As Excel.Application
- Set openApp = New Excel.Application
- openApp.DisplayAlerts = False
- openApp.Visible = True
- openApp.ScreenUpdating = False
- Dim openBook As Workbook
- Set openBook = openApp.Workbooks.Open(openWaN)
- For Each ws In openBook.Worksheets
- ws.Unprotect Password:="P$n177"
- afName$ = TrimFormats(actFile)
- sName$ = ws.Name
- Workbooks(afName).Worksheets(sName).Activate
- If fileHaveNum Then
- Range("G4:G4").Select
- ActiveWindow.FreezePanes = True
- Else
- Range("G6:G6").Select
- ActiveWindow.FreezePanes = True
- End If
- ws.Protect Password:="P$n177"
- Next
- openBook.Close SaveChanges:=True
- openApp.ScreenUpdating = True
- openApp.Quit
- End If
- y = y + 1
- Loop
- x = x + 1
- Loop
- End Sub
Add Comment
Please, Sign In to add comment