Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Workbook_Open()
- Dim tamanho As Variant
- Dim c As Variant
- Dim ot As Range
- Dim d_ot As Range
- Dim i_ot As Range
- Dim m As Range
- Dim ent As Range
- Dim inc As Range
- Dim falta As Range
- Dim file As Variant
- Dim subf As Variant
- Dim f
- Dim sf
- Dim ext
- 'Limpar área de trabalho
- Range("C10:I550").Clear
- Range("C10:I550").Select
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- Selection.Borders(xlEdgeLeft).LineStyle = xlNone
- Selection.Borders(xlEdgeTop).LineStyle = xlNone
- Selection.Borders(xlEdgeBottom).LineStyle = xlNone
- Selection.Borders(xlEdgeRight).LineStyle = xlNone
- Selection.Borders(xlInsideVertical).LineStyle = xlNone
- Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
- Const folder = "\\Host\EM_TRATAMENTO"
- 'Const folder = "F:\RQ\"
- Range("C10").Select
- Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
- Selection.ClearContents
- Selection.NumberFormat = "General"
- Range("C10").Select
- c = 10
- With CreateObject("Scripting.FileSystemObject")
- 'OT
- Set ot = ActiveSheet.Cells(10, 3)
- Set d_ot = ActiveSheet.Cells(10, 4)
- Set i_ot = ActiveSheet.Cells(10, 5)
- Set m = ActiveSheet.Cells(10, 6)
- Set ent = ActiveSheet.Cells(10, 7)
- Set inc = ActiveSheet.Cells(10, 8)
- Set falta = ActiveSheet.Cells(10, 9)
- For Each subf In .GetFolder(folder).SubFolders
- For Each file In .GetFolder(subf).Files
- If LCase(Left(.GetExtensionName(file.Name), 3)) = "xls" Then
- If Right(.GetBaseName(file), 3) = "REQ" Then
- ot.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$A$6"
- ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=file.ParentFolder & "\" & file.Name
- Set ot = ot.Offset(1)
- d_ot.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$B$9"
- Set d_ot = d_ot.Offset(1)
- i_ot.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$B$10"
- Set i_ot = i_ot.Offset(1)
- m.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$B$6"
- Set m = m.Offset(1)
- ent.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$H$7"
- Set ent = ent.Offset(1)
- inc.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$I$7"
- Set inc = inc.Offset(1)
- falta.Formula = "='" & file.ParentFolder & "\[" & file.Name & "]Folha1'!$J$7"
- Set falta = falta.Offset(1)
- c = c + 1
- Range(Cells(c, 3), Cells(c, 3)).Select
- End If
- End If
- Next
- Next
- tamanho = Range("C65536").End(xlUp).Row
- Range(Cells(10, 3), Cells(tamanho, 9)).Select
- Selection.Borders(xlDiagonalDown).LineStyle = xlNone
- Selection.Borders(xlDiagonalUp).LineStyle = xlNone
- With Selection.Borders(xlEdgeLeft)
- .LineStyle = xlDouble
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThick
- End With
- With Selection.Borders(xlEdgeTop)
- .LineStyle = xlDouble
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThick
- End With
- With Selection.Borders(xlEdgeBottom)
- .LineStyle = xlDouble
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThick
- End With
- With Selection.Borders(xlEdgeRight)
- .LineStyle = xlDouble
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThick
- End With
- With Selection.Borders(xlInsideVertical)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- With Selection.Borders(xlInsideHorizontal)
- .LineStyle = xlContinuous
- .ColorIndex = 0
- .TintAndShade = 0
- .Weight = xlThin
- End With
- Set ot = ActiveSheet.Cells(10, 3)
- Set ent = ActiveSheet.Cells(10, 7)
- Set inc = ActiveSheet.Cells(10, 8)
- Set falta = ActiveSheet.Cells(10, 9)
- For l = 10 To tamanho
- If ent <> 0 Then
- If inc = 0 Then
- If falta = 0 Then ot.Interior.ColorIndex = 43
- End If
- End If
- Set ot = ot.Offset(1)
- Set ent = ent.Offset(1)
- Set inc = inc.Offset(1)
- Set falta = falta.Offset(1)
- Next l
- Application.GoTo Reference:=Worksheets("Sobressalentes_por_OT").Range("B7"), scroll:=True
- End With
- End Sub
- https://lh3.googleusercontent.com/-lB9vFgXgQiw/TmeWtgGaA2I/AAAAAAAAA7k/3tN1sFHPb0g/s979/quadro%2Bresumo%2Brequisi%25C3%25A7%25C3%25B5es.jpg
Advertisement
Add Comment
Please, Sign In to add comment