View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JOUIOUI JOUIOUI is offline
external usenet poster
 
Posts: 72
Default Syntax error in code

I'm using this code in an existing macro to keep only rows with "F800" in
column J. All other rows are being deleted. The spreadsheet varies in
length every day so there is no end specified. The syntax error I'm
receiving in my code is on this line:

If StrComp(Cells(RowNdx, "J"), "F800", vbTextCompare) < 0
Then



Thanks for your help.

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