Guzzlr
Well-known Member
- Joined
- Apr 20, 2009
- Messages
- 982
- Office Version
- 2021
- Platform
- Windows
VBA Code:
For Each sht In ActiveWorkbook.Worksheets
If sht.Visible And sht.Name = "NCR" And sht.Name = "Planned" Then
sht.Activate
'Justify each Worksheet
With ActiveSheet
Cells.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
.RowHeight = 200
Rows("1:1").RowHeight = 32
Columns("B:B").ColumnWidth = 8.14
Columns("C:C").ColumnWidth = 20
Columns("D:D").ColumnWidth = 20
Columns("E:E").ColumnWidth = 62
Columns("F:F").ColumnWidth = 62
Columns("G:G").ColumnWidth = 62
' Rows("1:1").Select
' Selection.RowHeight = 32
End With
'Draw Border
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
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
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
'Delete all Unused Columns to End
Range("H:H", Cells(1, Columns.Count).End(xlToLeft).EntireColumn).Delete
End With
End If
Next sht
Hello All,
My code above is not working to justify or draw boarders. Basically, for the worksheets of NCR and Planned, I want to justify and draw boarders, then delete all columns from HH:HH to end.
However, My loop is skipping the two worksheets of NCR and Planned, and going right to the end.
How can I get the code to find the two sheets of NCR and Planned, then preform the proper formatting?
Thanks for the help