VBA代码
Sub kk()
For a = 3 To 758
For b = 3 To 13
yy = Left(Cells(1, b), 4)
mm = Right(Cells(1, b), 2)
If Cells(1, b) = 201206 Then n = 4 Else n = 3
If Cells(a, b).Value = 0 Then
For c = 1 To n
For nnn = 1 To 2
Endr = Cells(65536, 14).End(xlUp).Row + 1 '获取最后行行号
Cells(Endr, 14) = "QL-" & Cells(a, 1)
If nnn = 1 Then Cells(Endr, 15) = "车费" Else Cells(Endr, 15) = "手机费"
Cells(Endr, 16) = yy & mm '费用月份
Next nnn
mm = mm + 1
If mm = 13 Then mm = 1 & yy = y + 1
If mm < 10 Then mm = 0 & mm
Next c
End If
Next b
Next a
End Sub
功能是将表格区域中等于0的单元所对应的月份填充到相应的区域,并对表头处理。
网友评论