View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Sort out data with VBA

Might have been a wordwrap problem:

Sub DeleteRows()
Dim LastRow As Long
Dim RowNdx As Long
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(Cells(RowNdx, "B"), "assets", _
vbTextCompare) < 0 Then
Rows(RowNdx).Delete
End If
Next RowNdx
End sub

--
Regards,
Tom Ogilvy


"JOUIOUI" wrote:

Thanks Chip, this looks like it would work for me but I get this Compile
Error, " Expected Line Number or label statement or end statement". I'm not
sure what this means. Did I so something wrong, I did a straight copy and
paste into my existing macro

"Chip Pearson" wrote:

Try something like

Dim LastRow As Long
Dim RowNdx As Long
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(Cells(RowNdx, "B"), "assets", vbTextCompare) < 0
Then
Rows(RowNdx).Delete
End If
Next RowNdx



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JOUIOUI" wrote in message
...
I have a spreadsheet that will very in row count every day. I
only want to
keep the rows that contain the text "Assets". This criteria
will be in
column B. I have an existing macro that adds the page
formatting. Can I add
code to this macro to delete everything that does not include
Assets in
Column B. Thanks so much.