Claire Jackson
Board Regular
- Joined
- Jun 30, 2020
- Messages
- 76
- Office Version
- 2016
- Platform
- Windows
Hi, I have a very simple spreadsheet that filters and sorts via VBA but the conditional formatting isn't correct once it's been sorted so I'm thinking the best way to fix it is to use VBA to conditionally format the data after the other VBA codes have been ran. Basically the data is filtered on row 3 and the data is in the range A3:Y1500. I need it to format the row (A:Y) orange if the data in column M on each row is greater than zero. Can anyone help?
The code I'm using is as follows:
Private Sub Worksheet_Activate()
Sheet4.Range("A3:BA5000").AutoFilter Field:=2
Sheet4.Range("A3:BA5000").AutoFilter Field:=7
With Range("A3:BA5000")
.AutoFilter Field:=2, Criteria1:="*Middlesbrough*"
.AutoFilter Field:=7, Criteria1:="*Submit Costs*"
End With
With Range("A3:BA5000").CurrentRegion
.Sort .Range("J3"), xlAscending, Header:=xlYes
End With
End Sub
The code I'm using is as follows:
Private Sub Worksheet_Activate()
Sheet4.Range("A3:BA5000").AutoFilter Field:=2
Sheet4.Range("A3:BA5000").AutoFilter Field:=7
With Range("A3:BA5000")
.AutoFilter Field:=2, Criteria1:="*Middlesbrough*"
.AutoFilter Field:=7, Criteria1:="*Submit Costs*"
End With
With Range("A3:BA5000").CurrentRegion
.Sort .Range("J3"), xlAscending, Header:=xlYes
End With
End Sub