简体   繁体   English

VBA EXCEL 对于范围内的每个单元格

[英]VBA EXCEL for each cell in range

how to move to next cell without doing anything if condition is not met如果不满足条件,如何在不执行任何操作的情况下移动到下一个单元格

For Each Cel In Range("F22:F3000")
If IsEmpty(Cel.Value) = True Or Not IsDate(Cel.Value) Then
End If
Next Cel
If DateAdd("m", 2, Cel.Value) = Date Then
'Cel.Row(sRow).Select
ws_1.Rows(Cel.Row).EntireRow.Copy ws_2.Range("A" & Rows.Count).End(xlUp).Offset(1)
notify.Toast "My Title", "Message"
MsgBox "regarder la colonne Annotation", vbExclamation
End If
Next

error of compilation next without for next 没有 for 的编译错误

As you seem to be a beginner, let me show you how your code might look like, corrected and indented:由于您似乎是初学者,让我向您展示您的代码在更正和缩进后的样子:

For Each Cel In Range("F22:F3000")
  If IsEmpty(Cel.Value) = True Or Not IsDate(Cel.Value) Then
  End If

  If DateAdd("m", 2, Cel.Value) = Date Then
    'Cel.Row(sRow).Select
    ws_1.Rows(Cel.Row).EntireRow.Copy ws_2.Range("A" & Rows.Count).End(xlUp).Offset(1) notify.Toast "My Title", "Message"
    MsgBox "regarder la colonne Annotation", vbExclamation
  End If
Next Cel

As you see, I have removed the first Next Cel , you only can have one Next in a For -loop.如您所见,我删除了第一个Next Cel ,您在For循环中只能有一个Next

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM