性格いい人が優勝

エラーチェックマークの削除のサンプルコードですが、この場合は全てのセル範囲が対象になりますが、I列のみを削除する事は出来ないのでしょうか?色々試しましたがうまくいきません、教えて頂きたいのですが、よろしくお願い致します。

Sub Sample()
Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange
If Rng.Errors.Item(xlNumberAsText).Value = True Then
Rng.Errors(xlNumberAsText).Ignore = True
End If
Next
End Sub

A 回答 (2件)

こんばんは。



どちらも実際には試していませんが、最初からI列の範囲を対象にすれば良いかと思います。

Sub Sample()
Dim Rng As Range
For Each Rng In Range("I1:I" & Cells(Rows.Count, 9).End(xlUp).Row)
If Rng.Errors.Item(xlNumberAsText).Value = True Then
Rng.Errors(xlNumberAsText).Ignore = True
End If
Next
End Sub

若しくは、Rngが9(I列)かを確認すれば良いかと。

Sub Sample()
Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange
If Rng.Column = 9 Then
If Rng.Errors.Item(xlNumberAsText).Value = True Then
Rng.Errors(xlNumberAsText).Ignore = True
End If
End If
Next
End Sub
    • good
    • 1
この回答へのお礼

ありがとうございます。
どちらでも思い通り出来ました。
ありがとうございました。

お礼日時:2022/02/24 20:53

以下のようにしてください。



Sub sample()
Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange
If Rng.Column = 9 Then
If Rng.Errors.Item(xlNumberAsText).Value = True Then
Rng.Errors(xlNumberAsText).Ignore = True
End If
End If
Next
End Sub
    • good
    • 1
この回答へのお礼

ありがとうございます。
出来ました。

お礼日時:2022/02/24 20:52

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!

このQ&Aを見た人はこんなQ&Aも見ています


このQ&Aを見た人がよく見るQ&A