|
ww176185299 发表于 2014-4-12 14:25
版主你好,我用少量数据进行了测试,但发现提示不是很准确,麻烦审查下。
另外提醒能否在同一个对话框 ... - Private Sub Workbook_Open()
- Dim arrName, arrDate
- Dim iRow As Long, i As Long
- Dim sName1 As String, sName2 As String
- Dim dDate As Date
-
- With Sheets("管理人员名册")
- iRow = .Cells(Rows.Count, "B").End(xlUp).Row
- arrName = .Range("h2:h" & iRow).Value
- arrDate = .Range("v2:y" & iRow).Value
- End With
-
- For i = 1 To UBound(arrName)
- dDate = 0
- If Len(arrDate(i, 2)) Then dDate = DateValue(arrDate(i, 2))
- If Date < dDate And dDate - Date <= 15 Then
- sName1 = sName1 & arrName(i, 1) & ":" & dDate & vbCrLf
- End If
- dDate = 0
- If Len(arrDate(i, 4)) Then dDate = DateValue(arrDate(i, 4))
- If Date < dDate And dDate - Date <= 15 Then
- sName2 = sName2 & arrName(i, 1) & ":" & dDate & vbCrLf
- End If
- Next
- MsgBox "合同马上到期人员名单:" & vbCr & sName1 & vbCrLf & "试用马上到期人员名单:" & vbCr & sName2
- End Sub
复制代码 sName2里变量名写错了,导致输出显示错误。改好了。
|
|