Thread: IF NOT between
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Miree Miree is offline
external usenet poster
 
Posts: 90
Default IF NOT between

I have tried this already for some reason it deletes all the rows

"Nigel" wrote:

If .Cells(i) < UserForm7.TextBox5 Or .Cells(i) UserForm7.TextBox6 Then
.Cells(i).EntireRow.Delete
End If


--

Regards,
Nigel




"Miree" wrote in message
...
I curently have this code which works wonderfully, i need to adapt it to
delete a line if the value in column DW in NOT equal to or between the
values
in text boxes 5 and 6 (5 always being less than or equal to 6)

Dim rng As Range
Dim i As Long

Set rng = ActiveSheet.Range(Cells(1, "DW"), Cells(Rows.Count,
"DW").End(xlUp))

With rng
For i = .Rows.Count To 1 Step -1
If .Cells(i) = UserForm7.TextBox5 Then
.Cells(i).EntireRow.Delete
End If
Next i
End With

All help very much appreciated

Thanks