mercredi 21 mars 2018

VBA IF statement works when condition is met but get mismatch error when condition not met.

VBA beginner here... This is probably a simple solution I am overlooking but I could not find other questions that fixed my issue. I am using the below code to delete the first row if cell B1 is not #N/A...otherwise do nothing.

If [B1].Value <> "#N/A" Then
[B1].EntireRow.Delete
End If

If the condition is met, the first row is deleted and the code works perfectly. However, if the condition is not met I get a mismatch error (instead of just moving on to the next line). Any ideas? Thanks.

Aucun commentaire:

Enregistrer un commentaire