Guzzlr
Well-known Member
- Joined
- Apr 20, 2009
- Messages
- 982
- Office Version
- 2021
- Platform
- Windows
Hello All
This code will add and format a new "Alignment" sheet correctly. But what if there is no "Alignment" sheet already in the workbook? This is where I'm having problems using an ElseIf statement, it seems it wants to keep adding multiple worksheets...
I got irritated and deleted the Else part of it.
Sorry
Code:
For Each sht In ActiveWorkbook.Worksheets
If sht.Visible And (sht.Name = "Alignment") Then
sht.Delete
Sheets.Add.Name = "Alignment"
sht.Activate
Cells.Select
With Selection
.Clear
.RowHeight = 20.01
.ColumnWidth = 8.43
Columns("B:C").ColumnWidth = 19.01
.NumberFormat = "0.00"
.Font.Name = "Calibri"
.Font.Size = 12
.Interior.Pattern = xlNone
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
Range("B2") = "MES Document"
Range("B2").Interior.ColorIndex = 4
' Range("D6") = "Not Used"
' Range("D6").Interior.Color = RGB(255, 157, 91)
Range("A1").Select
End With
End If
Next sht
This code will add and format a new "Alignment" sheet correctly. But what if there is no "Alignment" sheet already in the workbook? This is where I'm having problems using an ElseIf statement, it seems it wants to keep adding multiple worksheets...
I got irritated and deleted the Else part of it.
Sorry