zookeepertx
Well-known Member
- Joined
- May 27, 2011
- Messages
- 576
- Office Version
- 365
- Platform
- Windows
I'm trying to format 2 worksheets at the same time. Part of the formatting is working on both sheets, but the column widths are not. I've tried every syntax change I can think of but obviously I'm missing something!
The current code is below; the 2 sheets are called "Combined" and "Comb-Ocean". The text color, cell colors, the borders are all formatting like you'd expect; it's ONLY the column widths that are the problem. The formatting is working correctly on "Combined" but not on "Comb-Ocean". This is all part of a larger macro, but I've isolated this part, since it's the only part that's being a pain.
There are numerous other worksheets in the workbook but I only need to format these 2.
Can someone tell me what's wrong with this?
Thank you.
Jenny
The current code is below; the 2 sheets are called "Combined" and "Comb-Ocean". The text color, cell colors, the borders are all formatting like you'd expect; it's ONLY the column widths that are the problem. The formatting is working correctly on "Combined" but not on "Comb-Ocean". This is all part of a larger macro, but I've isolated this part, since it's the only part that's being a pain.
VBA Code:
Sub Macro15()
' Macro15 Macro
Sheets(Array("Combined", "Comb-Ocean")).Select
Cells.Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.ColorIndex = xlAutomatic
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
With Selection.Borders
.LineStyle = xlNone
End With
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.RowHeight = 12
With Selection
Range("A:B").EntireColumn.AutoFit
Columns("C:D").ColumnWidth = 3.29
Columns("E:E").ColumnWidth = 4.17
Columns("F:F").ColumnWidth = 9
Columns("G:G").ColumnWidth = 22.14
Columns("H:H").ColumnWidth = 19.86
Columns("I:W").ColumnWidth = 6.29
End With
End Sub
There are numerous other worksheets in the workbook but I only need to format these 2.
Can someone tell me what's wrong with this?
Thank you.
Jenny