Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi...
I'm looking for code that will go into an auto_open macro that will automatically filter column B6:B2000 to the value todays date [if the range has a cell with todays value in it]. If the range doesn't have todays date in it then no action is taken. It sounds simple but I'm struggling... Any help appreciated... Gordon. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Create a macro that filters for today's date. Then, in the ThisWorkbook
module, add code to the Workbook_Open event, to run that macro. '========================== Private Sub Workbook_Open() FilterToday End Sub '=========================== '================================ 'this procedure is stored in a regular module Sub FilterToday() Dim rng As Range Dim rngF As Range Dim ws As Worksheet Dim LastRow As Long Dim strDate As String strDate = Format(Date, "m/d/yy") Set ws = Sheets("Pivot Data") 'remove any existing filter If ws.AutoFilterMode Then ws.Cells.AutoFilter End If With ws .Range("A1").AutoFilter Field:=1, _ Criteria1:=strDate End With Set rng = ws.AutoFilter.Range Set rngF = Nothing On Error Resume Next With rng 'count the rows Set rngF = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _ .SpecialCells(xlCellTypeVisible) End With On Error GoTo 0 If rngF Is Nothing Then ws.Cells.AutoFilter End If End Sub '======================== Gordon wrote: Hi... I'm looking for code that will go into an auto_open macro that will automatically filter column B6:B2000 to the value todays date [if the range has a cell with todays value in it]. If the range doesn't have todays date in it then no action is taken. It sounds simple but I'm struggling... Any help appreciated... Gordon. -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Auto filtering | Excel Worksheet Functions | |||
auto filtering? | Excel Worksheet Functions | |||
Auto Start | Excel Discussion (Misc queries) | |||
how do I set up an auto start macro | Excel Programming | |||
AUTO START | Excel Programming |