I am trying to delete a row if cells in column V is not equal to F or V.
This code deletes everything.
For i = RowCo
Your logic seems incorrect. By changing the or
to an and
, you will then be evaluating the proper boolean arithmetic.
Right now, you are checking not "v"
and not "f"
which is always false.
No matter the input, this will always have answer be true.
Answer to Else Not working in "If Then Else" in VBA EXCEL
You need something similar
Sub SpecificFlatArrears03()
Dim Flat As Variant
Do
Flat = InputBox("Pl Enter a Flat Number as 3 Digit without Prefix")
'at this point you should check that Flat meets the required requirements
Range("h3").Value = Flat
If (Flat > 100 And Flat < 165) Or (Flat > 200 And Flat < 264) Or (Flat > 300 And Flat < 364) Or Flat = 403 Or Flat = 404 Or Flat = 462 Or Flat = 463 Then
Range("h4") = WorksheetFunction.Match(Flat, Range("'2020-2021'!d11:d206"), 0)
Exit Do
End If
Loop Until False
End Sub