我是编码 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
在开始时添加一些简单的代码将使一切变得简单
If Application.WorksheetFunction.CountIf(countsheet.Range("K:K"), Date) = 0 Then
MsgBox "Today's Date Not Found"
Exit Sub
End If
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句