Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This procedure is used to delete any records where a negative sign exists
anywhere in a value in the D column. It works fine with multiple records, but if there is only one record in the file, with or without a negative sign in the file being formatted, the record is deleted. If I change the SpecialCells Method to r.SpecialCells(xlCellTypeAllValidation) it doesn't delete the one record but also does not remove records where the negative sign exists when multiple records exist. Here is a sample file with 2 records. One has a negative sign, the other does not and therefore should not be deleted. A,1111111111,042804,030171,13174.20 A,1111111111,041904,030221-,4243.30 How can I change this to work in both situations? Sub CleanCancelledChks() Dim r As Range Dim r1 As Range With ActiveSheet Set r = .Range(.Range("D2"), .Range("D" & _ Rows.Count).End(xlUp)) .Columns("D:D").AutoFilter Field:=1, Criteria1:="=*-*" On Error Resume Next 'Extra variable is to prevent specialcells method from returning error1004 when no negative values(ie. cancelled chks) exist. Set r1 = Nothing Set r1 = r.SpecialCells(xlCellTypeVisible) On Error GoTo 0 .AutoFilterMode = False If Not r1 Is Nothing Then _ r1.EntireRow.Delete End With End Sub Thanks, |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Please post this thread a correct full method, method about | New Users to Excel | |||
Please post this thread a complete correct method, method about te | New Users to Excel | |||
Specialcells | Charts and Charting in Excel | |||
specialcells method errors when criteria not found | Excel Programming | |||
SpecialCells(xlCellTypeFormulas) | Excel Programming |