细胞格式改变

时间:2015-11-10 15:56:02

标签: excel vba

我想在每个工作表上更改单元格B4中的格式,除了第一个和最后一个,并执行此操作:

Dim num As Integer
num = ActiveWorkbook.Sheets.Count
For i = 2 To num - 1
    ActiveWorkbook.Sheets(i).Range(B4).NumberFormat = "00"
Next i

首先,我正在检查工作表的数量,然后从Sheet到最后一张工作表之前,但是我收到错误:/

1 个答案:

答案 0 :(得分:0)

在定义范围时添加引号:

Dim num As Integer
num = ActiveWorkbook.Sheets.Count
For i = 2 To num - 1
    ActiveWorkbook.Sheets(i).Range("B4").NumberFormat = "00"
Next i