摘要:我有一个使用循环在 A 列中循环的策略编号for each
列表
问题:一切正常,除非 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"))
提前感谢您的帮助!:)