Thread: Macro help
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default Macro help

This macro will do what you want. I assumed your data went from A2 to Hx
where "x" is any number you wish. Change this as needed to fit your data.
HTH Otto
Sub CleanUp()
Dim RngColA As Range
Dim i As Range
Dim c As Long
Application.ScreenUpdating = False
Set RngColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For c = RngColA.Count To 1 Step -1
If RngColA(c).Offset(, 5) < "RED" And _
RngColA(c).Offset(, 5) < "WHITE" And _
RngColA(c).Offset(, 5) < "BLUE" Then _
RngColA(c).EntireRow.Delete
Next c
Set RngColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each i In RngColA.Resize(, 8)
i.Value = Application.Trim(i.Value)
Next i
Application.ScreenUpdating = True
End Sub
"hshayh0rn" wrote in message
...
I need some help cleaning up a spread sheet. I have several worksheets with
data on them. I would like to delete any rows of data that don't contain
one
of 3 or 4 specific values in column F of that row. For example if column F
of
row 1 does not contain the word "RED", "WHITE" or the word "BLUE" then
delete
the row. Also, some of the columns have spaces in the beginning and at the
end of the actual value that I need removed at the same time. For example
a
field may have " Free Checking is Here " and I need all of
the
spaces on the end of that value removed but retaining the spaces between
the
words. Lastly, row 1 on all of the sheets contains a header row. Any help
is
GREATLY appreciated!! Thanks in advance.