any reason work filtering data and suddenly shows error application defined

Abdo

Board Regular
Joined
May 16, 2022
Messages
183
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Hi
I would from the expert to find out the problem about suddenly error application defined in this line
VBA Code:
.Offset(-1).AutoFilter 1, "<0"
this occures when I fill the cells in column C . the column D,E is usaully empty or contains zero value before i fill any thing in theses columns .
the error not always shows but somtimes .
VBA Code:
Sub HighlightNegatives()
With Range("F2", Range("F" & Rows.Count).End(3))
   .Font.Color = vbBlack
   .Font.Bold = False
   .Offset(-1).AutoFilter 1, "<0"
   On Error Resume Next
   With .SpecialCells(12)
      .Font.Color = vbRed
      .Font.Bold = True
   End With
   On Error GoTo 0
   .AutoFilter
   .Offset(, 1) = Evaluate(Replace("if(@<0,""the  sales is  bigger than purchase"","""")", "@", .Address))
   .Offset(, 1).Font.Color = vbRed
   .Offset(, 1).Font.Bold = True
End With
I hope finding solution soonly.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top