行,Excel VBA再次击败了我。我怀疑,当我看到答案时,我会觉得自己像个白痴。幸运的是,随着年龄的增长,我正逐渐适应这种情况。这里是我的代码:多张表格格式第1行粗体文字换行
Option Explicit
Sub FormatAllSheets()
Dim shNames()
ReDim shNames(Worksheets.Count - 1)
Dim shIndex As Integer
For shIndex = 0 To UBound(shNames)
shNames(shIndex) = Worksheets(shIndex + 1).Name
Next shIndex
Range("A1", "ZZ1").Select
Sheets(shNames).Select
Selection.Font.Bold = True
Selection.WrapText = True
End Sub
非常感谢, 托尼·利马
你的代码不工作的原因是因为可怕的'Select'关键字。当你做了Range(“A1”,“ZZ1”)。选择你选择的范围。但是你做了'Sheets(shNames).Select',它只是选择了数组中的纸张(有点像按住CTRL并点击所有纸张)。你*可以*多选范围,就像你想的那样,就是不那样。最好遍历表单,引用范围并格式化单元格(不使用“Select”)。除特殊情况外,我总是远离“选择”。 – 2015-02-24 02:48:03
谢谢,乔。 “确实可怕的选择”。 – 2015-02-24 18:23:42