View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joeu2004[_2_] joeu2004[_2_] is offline
external usenet poster
 
Posts: 829
Default Basic Row Delete Marco

"SalientAnimal" wrote:
I'm looking for a very basic marco that will delete an
entire row if the cell in column U contains any text/value.


Not sure what you mean by "any text/value". Do you really mean "a specific
value"? Or do you mean "not a formula and not empty"? Do you mean simply
"not empty"?

I assume you mean "a specific value".

The following will delete rows conditionally over a selected region.


Sub doit()
Const mycol = "U"
const myval = 4 ' your "specific value" (my assumption)
Dim nr As Long, i As Long
Dim rng As Range, r as Range
Application.ScreenUpdating = False
rng = Selection ' your own range
nr = rng.Rows.Count
' important: process rows in reverse when deleting
For i = nr To 1 Step -1
Set r = rng.Cells(i, 1).EntireRow
If r.Cells(1, mycol) = myval Then r.Delete
Next
Application.ScreenUpdating = True
End Sub