概要:ループを使用して列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"))
助けてくれてありがとう!:)