我是VBA编码的新手。我想添加一个弹出框,显示消息“今天未找到今天”,如果在K列中未找到今天的日期,则停止宏。不确定如何执行此操作以及代码应在哪里。
' Find the last row on the count sheet and the next row on the archieve sheet
lastRow = countSheet.Cells(countSheet.Rows.count, "K").End(xlUp).Row
nextRow = archieveSheet.Cells(countSheet.Rows.count, "K").End(xlUp).Row + 1
' Look at all rows in the count sheet
For thisRow = 1 To lastRow
' Check if column K contains today's date
If countSheet.Cells(thisRow, "K").Value = Date Then
' Copy the entire row to the archieve sheet
countSheet.Cells(thisRow, "K").EntireRow.Copy Destination:=archieveSheet.Cells(nextRow, "A")
' Move to the next row on the archieve sheet
nextRow = nextRow + 1
End If
Next thisRow
Run Code Online (Sandbox Code Playgroud)
在开始时添加一些简单的代码将使所有事情保持简单
If Application.WorksheetFunction.CountIf(countsheet.Range("K:K"), Date) = 0 Then
MsgBox "Today's Date Not Found"
Exit Sub
End If
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
103 次 |
| 最近记录: |