ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not recognising value (https://www.excelbanter.com/excel-programming/379427-not-recognising-value.html)

keri

Not recognising value
 
I need to delete any rows where the value in column I is "INCOMPLETE".
I tried writing the code myself but it wasn't recognising the cells
that said "Incomplete". So I have searched the forums to find the code
below which I thought would do the job with a bit of altering. However
on stepping through the code it is not recognising cells that say
INCOMPLETE either and is just continuing through the code without
executing the delete row.

Sub deleteincompleterows()

Dim rng As Range, cell As Range, arrVar As Variant
Dim strAddress1 As String, rngUnion As Range
Set rng = Range("I5:I8")

For Each arrVar In Array("INCOMPLETE*")
Set cell = rng.Find(arrVar, LookIn:=xlValues, Lookat:=xlWhole,
MatchCase:=True)

If Not cell Is Nothing Then
strAddress1 = cell.Address
Do
If rngUnion Is Nothing Then
Set rngUnion = cell
Else
Set rngUnion = Union(cell, rngUnion)
End If
Set cell = rng.FindNext(cell)
Loop While Not cell Is Nothing And _
cell.Address < strAddress1
End If
Next arrVar
If Not rngUnion Is Nothing Then
rngUnion.EntireRow.Delete
End If
End Sub

Is this an obvious problem with my code or is it a problem with the
values on my sheets?



All times are GMT +1. The time now is 03:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com