首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在5小时后在excel中获得提醒提醒?

如何在5小时后在excel中获得提醒提醒?
EN

Stack Overflow用户
提问于 2017-04-09 00:59:18
回答 2查看 691关注 0票数 0

我想在excel中使用VB或Macros在5小时后收到通知警报?

EN

回答 2

Stack Overflow用户

发布于 2017-04-09 01:02:24

您可以使用以下三种方法在MS Excel中快速轻松地创建提醒或通知:

  1. 使用IF函数显示消息

代码语言:javascript
复制
- `=IF(B2<TODAY()+3,"Send Reminder","")`

  1. 使用条件格式

代码语言:javascript
复制
- Click on Home Tab
- In the Styles command group select conditional formatting tab
- Click on New Rule…
- In the new formatting rule window select ‘Use a formula to determine which cells to format’
- Under the ‘Format values where this formula is true:’ write the formula given below
- `=AND(C2<>"",C2<TODAY()+3)` 
- Next click on Format and apply the formatting of the cell and font of your choice

  1. 使用带有for loop的Excel VBA。宏代码如下:

Private Sub Workbook_Open() For Each cell In Range("B2:B100") If cell.Value < Date + 3 And cell.Value <> “” Then cell.Interior.ColorIndex = 3 cell.Font.ColorIndex = 2 cell.Font.Bold = True End If Next End Sub

Private Sub Workbook_Open()下,您还可以使用以下代码行来初始化上述宏代码中的格式设置

Range("B2:B100").Interior.ColorIndex = xlNone

票数 0
EN

Stack Overflow用户

发布于 2017-04-09 01:41:26

从VBA调用WinAPI是有风险的,但您也可以尝试:

代码语言:javascript
复制
Option Explicit

Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal idEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal idEvent As Long) As Long

Public Sub AlertMe(dblMinutes As Double)
    Dim idEvent As Long: idEvent = SetTimer(0&, 0&, CLng(dblMinutes * 60 * 1000), AddressOf AlertSub)
End Sub

Public Sub AlertSub(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
    KillTimer 0&, idEvent
    MsgBox "Alert!"
End Sub

您可以将此文件保存到例如Personal.xls,然后这样调用它:

代码语言:javascript
复制
AlertMe 300 ' minutes
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43297913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档