都係只識做current sheet
Sub border()
Dim ws As Worksheet, x As Integer, i As Integer
ThisWorkbook.Activate
x = 7
For i = x To Worksheets.Count
Set ws = Worksheets(i)
With ws
If Right(ActiveSheet.Name, 4) = "_PDT" Then
Range("BA25:BA44,BA46:BA65,BA67:BA86,BA88:BA107,BA109:BA128,BA230:BA249,BA251:BA270,BA272:BA291,BA293:BA312,BA314:BA333,BA335:BA354,BA456:BA475,BA477:BA496,BA498:BA517,BA519:BA538,BA540:BA559").Select
Range("BA540").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
ElseIf Right(ActiveSheet.Name, 4) = "_L&D" Then
Range("BA24:BA43,BA45:BA64,BA66:BA85,BA87:BA106,BA108:BA127,BA129:BA148,BF24:BF43,BF45:BF64,BF66:BF85,BF87:BF106,BF108:BF127,BF129:BF148").Select
Range("BA24").Activate
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
End If
End With
Next
End Sub |