摘要:我有政策号码我是用for each
环圈穿过列的列表需要ForEach循环对象错误
问题:一切正常,只是如果在列空单元格A,我的代码会删除整行(因为它应该),但是当我尝试设置policy
变量时,我得到一个object required
错误。我在代码中标记了发生错误的位置。
问题:如何在没有theCell
的情况下删除空行而丢失其对象?
验证码:
Dim theRange As Range
Dim theSheet As Worksheet
Dim theDate As String, policy As String, amount As String, details As String, entryDate As String
Set theSheet = Sheets("OneDate")
Set theRange = Range("A2:A" & theSheet.UsedRange.Rows.Count)
For Each theCell In theRange 'FOR EACH POLICY IN COLUMN "A"
If theCell.Value = "" Then
theCell.EntireRow.Delete '<-- Row deleted here
MsgBox (theCell.Value)
End If
policy = theCell.Value '<-- Error occurs here
theDate = theCell.Offset(0, 1).Value
theDate = UCase(Format(theDate, "ddMMMyy"))
在此先感谢您的帮助! :)
+1格式良好且清晰的问题。 – nutsch