LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Select rows equal to filter and highlight row

Hi again John,

I was short on time earlier but I have now had a closer look at your code
and if I am interpreting correctly what you want to do then I think it should
be more like the following. Note that I have removed existing filters and
cleared any existing interior formatting before setting the filter again and
setting the interior color of the visible cells.

Sub MarkNewPlayers()

Dim afterDate As String
Dim myDate As String
Dim wrksMain As Worksheet
Dim lastRow As String
Dim rngFiltered As Range

Set wrksMain = Worksheets("PlDetails")

' Message Box opens to enter the Date to use in the file name
myDate = InputBox _
("Please enter your date in mm/dd/yyyy format:", _
"What date do you want to enter?", "mm/dd/yyyy")

If myDate = "" Or Not IsDate(myDate) Then
MsgBox "You did not enter a date.", 48, "Action cancelled."
Exit Sub
Else
afterDate = myDate
End If

lastRow = Cells(Rows.Count, 1).End(xlUp).Row

'Clear existing filters (if any)
With wrksMain
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
End If
End With

'Clear existing interior colors
With wrksMain.Range("$A$1:$AL$" & lastRow).Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With

'Set AutoFilter on Field 4
wrksMain.Range("$A$1:$AL$" & lastRow) _
.AutoFilter Field:=4, _
Criteria1:="" & afterDate

'Set rngFiltered to just the visible cells
With wrksMain.AutoFilter.Range
Set rngFiltered = .Offset(1, 0) _
.Resize(.Rows.Count - 1, .Columns.Count) _
.SpecialCells(xlCellTypeVisible)
End With

'Set interior color of visible cells
With rngFiltered.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
.PatternTintAndShade = 0
End With

End Sub

--
Regards,

OssieMac


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
highlight row if cell value equal zero amanda Excel Programming 2 January 9th 09 06:53 PM
Filter and select the upmost rows Ranjit kurian Excel Programming 2 April 28th 08 05:26 PM
Highlight the lowest number - only if it does not equal another va JJ2356 Excel Discussion (Misc queries) 6 April 17th 08 10:10 PM
Excel data filter collapses rows even after I select show all!?!?!? [email protected] Excel Discussion (Misc queries) 4 January 9th 07 12:42 PM
Filter/Select multiple rows a_moron Excel Discussion (Misc queries) 5 January 20th 06 02:41 PM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"