generalgort
New Member
- Joined
- Jun 5, 2010
- Messages
- 10
Hi Guys,
I have written a macro for a spreadsheet so that when one of the header 'buttons' is clicked, the cells containing that colour are filtered.
The problem is whichever 'button' is pressed, the first row in the column is always filtered in regardless of it's colour, and changing the range doesn't seem to work.
Here's the code:
Private Sub Button2100_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(255, _
255, 0), Operator:=xlFilterCellColor
End Sub
Private Sub ButtonLO_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(83, _
126, 213), Operator:=xlFilterCellColor
End Sub
Private Sub ButtonEE_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(250, _
192, 144), Operator:=xlFilterCellColor
End Sub
Private Sub buttonClear_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1
End Sub
Hope you can help
Phil.
I have written a macro for a spreadsheet so that when one of the header 'buttons' is clicked, the cells containing that colour are filtered.
The problem is whichever 'button' is pressed, the first row in the column is always filtered in regardless of it's colour, and changing the range doesn't seem to work.
Here's the code:
Private Sub Button2100_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(255, _
255, 0), Operator:=xlFilterCellColor
End Sub
Private Sub ButtonLO_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(83, _
126, 213), Operator:=xlFilterCellColor
End Sub
Private Sub ButtonEE_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1, Criteria1:=RGB(250, _
192, 144), Operator:=xlFilterCellColor
End Sub
Private Sub buttonClear_Click()
ActiveSheet.Range("$G$7:$G$28").AutoFilter field:=1
End Sub
Hope you can help
Phil.