View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Lillian[_3_] Lillian[_3_] is offline
external usenet poster
 
Posts: 7
Default delete record using Macro in excel spreed sheet

What you meant by trim data? I went to this web site, I
am not sure how to do, please help.

thanks.

Lillian

-----Original Message-----
See this site for a macro te trim your data

http://www.mvps.org/dmcritchie/excel/join.htm#trimall

Then use this

Sub Test()
Dim r As Long
Application.ScreenUpdating = False
With Worksheets("Sheet1")
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "A").Value = "----" Or _
.Cells(r, "A").Value = "problem" Or _
.Cells(r, "A").Value = "" Or _
.Cells(r, "A").Value = "" Then
.Rows(r).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



wrote in message

...
I use your original code, all the "problem" "-----"
records is gone, but I still have a lots of empty row,
how can I delete them, also some of records on columnF
has spaces " ", how can I delete them, thanks for all

the
help, you are a genius.

Can I use the following code:

Sub Test()
Dim r As Long
Dim s As String
Application.ScreenUpdating = False
With Worksheets("sheet1")
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "A").Value = "----------" Or _
.Cells(r, "A").Value = "PROBLEM" Or _
.Cells(s, "A").Value = " " Or _
.Cells(s, "F").Value = " " Then
.Rows(r).Delete
.Rows(s).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub

thanks.

Lillian
-----Original Message-----
I forgot to type the screenupdating

Sub Test()
Dim r As Long
Application.ScreenUpdating = False
With Worksheets("Sheet1")
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "A").Value = "----" Or _
.Cells(r, "A").Value = "problem" Then
.Rows(r).Delete
End If
Next
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Ron de Bruin" wrote in

message ...
Try this(is not fast)

I don't know what you mean by space?
You can add things to the macro yourself

Sub Test()
Dim r As Long
With Worksheets("Sheet1")
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "A").Value = "----" Or _
.Cells(r, "A").Value = "problem" Then
.Rows(r).Delete
End If
Next
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Lillian" wrote in message

...
I have one excel spreed sheet, it about 30,000

records, I
need to deleted some of records, if columnsA
has "problem", the record will be delete, if rows

is
space, the record will be delete, if ColumsA

has "---
-",
the record will be delete, if column(F) has space,

the
record will be delete.

How can I write the macro to delete those record,

thanks
for the help.

Lillian





.



.