我有一些数据,看起来像这样:循环在一定范围内,逐行
对于标有“优惠券”我想,如果他们加入这一行中的数字,该项目的所有行非空白。如果它们是空白的,我想让它们独自一人。另外,如果单元格中的数据碰巧是日期,我不想触摸它。
逐行我想贯穿整个范围。
我目前的代码给我一个“对于每个可能只能迭代集合对象或数组vba”错误。请帮忙!
Sub CommandButton1_Click()
Dim rng As Range
Dim rw As Range
Dim cel As Range
Set rng = Range("E15:P464")
For Each rw In rng.Row
If rw.Item(1, 1) = "coupon" Then
For Each cel In rw.Cells
If IsEmpty(cel.Value) = False Then
If Not IsDate(cel) Then
cel.Value = cel.Value + 0.0001
End If
End If
Next cel
End If
Next rw
End Sub
你想'rng.Rows'与s –
你会还需要'rw.Cells(1,1)'而不是'rw.Item(1,1)'。项目会给出一个“应用程序定义或对象定义的错误”。 –
@chrisneilsen Thx。将它更改为行后,我得到“运行时错误1004:应用程序定义或对象定义的错误” – Amatya