【发布时间】:2016-07-15 17:16:36
【问题描述】:
当我通过 FOR LOOP 时,我试图在单个单元格周围设置边框,其中循环的数量取决于其中包含内容的列数,并且列数会因工作表而异。
看来我不能单独在动态单元格位置周围设置边框,而是必须指定范围或特定单元格。那是对的吗?
这是我用来实现目标的代码...
Sub Sheet_Formatting()
For Col_Count = 1 To Col_Count_Active_Sheet
ThisWorkbook.Worksheets(Active_Sheet).Cells(1, Col_Count).Interior.Color = RGB(100, 100, 100) ' sets to the color ???
ThisWorkbook.Worksheets(Active_Sheet).Cells(1, Col_Count).Borders.LineStyle.xlContinuous ' sets to the linestyle
ThisWorkbook.Worksheets(Active_Sheet).Cells(1, Col_Count).Borders.Weight.xlThick ' sets to the border thickness
ThisWorkbook.Worksheets(Active_Sheet).Cells(1, Col_Count).Font.Bold = True ' sets to the text format to bold
Next Col_Count
End Sub
我相信有一种方法可以完成边框规范,但我不能使用“单元格”来指定任何边框。内部颜色和字体根据需要工作。
【问题讨论】:
标签: vba excel formatting