More Selecting and Deleting

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dim lastrow As Long, i As Long
Dim cell As Range

lastrow = Cells(Rows.Count, "I").End(xlUp).Row
For i = lastrow To 1 Step -1
Set cell = Cells(i, "I")
If IsNumeric(cell) Then
If cell < 7 Then
cell.Offset(0, -4).Resize(1, 6).Delete shift:=xlToLeft
End If
End If
Next

This formula works great to do the following: If the value in the cell is
less than 7 it will select columns 1 - 6 and delete that row selection then
shift all cells to the right over left into it's place.

I want the "If Cell < 7 Then" to be more like:

If the cell value is anything but 1 or 7 then delete the selection. So
something like If Cell < 1 And betwee 1 & 7 then delete selection. I'm
probably making this way too complicated, and I'm not programming savvy
enough to figure out the line of code. THANKS!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top