View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
orquidea orquidea is offline
external usenet poster
 
Posts: 132
Default Macro to delete specific cells

Hi

Thanks for your answer. It worked. I took a 3 days course on macros but
this subjet is too complex to understand in 3 days. So, I may ask silly
questions but asking for clarification is the only way that I learn.
What does it do .Cells?
What does the instruction Set do?
Thanks in advance

Orquidea


If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)





"JE McGimpsey" wrote:

One way:

Dim rCell As Range
Dim rDelete As Range
For Each rCell In Range("E1:E70")
With rCell
If Not .Text = "CNR001" Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
End With
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete


In article ,
orquidea wrote:

Hi
I have a range of data from A1 to G70
I want to set a macro that deletes the whole rows that column E is not
equal to CNR001. The number of rows will be diferent every time.

Thanks in advance

Orquidea