好日子,所有人,目前我仍然面临着我的老板任务的问题,创建一个MS Excel宏。MS excel宏自动计数功能
问题现在面临的是
- 自动计数的消息框,当用户打开的工作表过时的数据并显示。
我曾试图从互联网资源这么多的代码,但结果还是一样,它不能运行代码或计数数为0
任何一个有任何建议或解决方案。谢谢。
下面是2错误作弄
这作弄将只显示0过时的数据量。
CountedAmount = Application.WorksheetFunction.CountIf(范围( “L4:L1048576”), “红”)
这在作弄我不会跑,预警秀运行时错误1004应用程序定义或对象定义的错误
CountedAmount = Application.WorksheetFunction.CountIf(范围( “L4:xlUp”), “红”)
这些都是我的微距完整的作弄。
Sub Worksheet_Activate()
Dim CountedAmount As Integer
With Worksheets("Sheet1")
lastrow = Range("L1048576").End(xlUp).Row
'This codding will only display 0 amount of outdated data.
CountedAmount = Application.WorksheetFunction.CountIf(Range("L4:L1048576"), "Red")
'This codding will not running, warning show up Run-time error 1004 Application-defined or object-defined eror
'CountedAmount = Application.WorksheetFunction.CountIf(Range("L4:xlUp"), "Red")
For i = 4 To lastrow
If Range("L" & i).Value <> "" And Now <> "" Then
If Range("L" & i).Value <= Now Then
MsgBox CountedAmount & " expiring"
Range("L" & i).Font.ColorIndex = 3
End If
End If
Next i
End With
End Sub
如果单元格的值为“红色”Application.WorksheetFunction.CountIf(范围(“L4:L1048576”),“红色”),但如果要计算红色的单元格数量,你必须找到其他的东西 – gizlmo