Excel VBA Autofilter Not Working With Date Column
Nov 4, 2013
I got a problem using AutoFilter with VBA in Excel.
It works well for regular filters, but filtering the date column does not work as intended. The column is formatted as date, I can filter it manually and absurdly, if I run my code, it filters nothing but when I check the filter and then only click ok (no change being applied to the filter criteria), it starts filtering correctly.
Here is my code:
Code:
ws.ListObjects(SheetName).Range.AutoFilter Field:=3, Criteria1 _
:=">" & CDate([datecell]), Operator:=xlAnd, Criteria2:= _
"
View 1 Replies
ADVERTISEMENT
May 20, 2012
I need a function to work out what the date will be 45 WORKING days after today(), this function needs to exclude Saturdays, Sundays and any Public Holidays i.e. there could be either 10 or 12 weekend days added into the calculation depending on when today() is plus any additional Public Holidays.
I am using Excel 2003 although it will need to work in Excel 2010 shortly.
View 4 Replies
View Related
Aug 26, 2013
I have a table and the first column headed "Arrival Date" contains dates. I then have some buttons on a form which enable me to quickly filter the table to show "Arrived Today", "Arrived Yesterday" and "Arrived last 3 days". The today and yesterday macros work fine, for example, the following code is used to filter for "Arrived Yesterday"
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=Format(Now() - 1, "dd/mm/yyyy")
The problem is the filter does not work for "Arrvied last 3 days", the code for which is as follows:
ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:=">=" & Format(Now() - 3, "dd/mm/yyyy")
When I apply his macro it displays no records and yet if I manually go into the filter everything appears to be OK. If I then use the date picker within the filter to essentially re-select the date that the macro has already specified then the filter works.
View 3 Replies
View Related
Feb 20, 2007
What could make this line of code stop working. It has worked for weeks, and just yesterday it stopped working. :x
ActiveWorkbook.Sheets("Email").UsedRange.AutoFilter Field:=2
The sheet is unprotected, and events are enabled. I don't know of anything different than before. What do I look for that would not allow this code to run?
View 9 Replies
View Related
Mar 17, 2014
Is there by any chance a work around for using a multiple auto filters on one worksheet using combo boxes ? An exmple of dummy data is :
Sales Rep<-filter here
Paul500
John600
Tom900
Andy450
Mark300
Sales by Region<-and here
North120
South360
East480
West490
North East250
North West500
South West290
South East260
View 2 Replies
View Related
Dec 20, 2012
When I either manually check the box for allowing sorting and autofiltering, or I do it through vba with:
Code:
With Sheets("Inventory")
.Protect Password:="###", AllowSorting:=True, AllowFiltering:=True, AllowUserInterface:=True
.EnableAutoFilter = True
End With
I still am unable to use the icons. The icons are clickable to filter or sort, but every time they say that the cells I am selecting are protected. I want them to be protected from editing the data, but want to allow them to be sorted or filtered.
View 1 Replies
View Related
Oct 12, 2012
I thought I had been able to use array to have more than two criterias with Autofilter, but now I am unable to make the following code work. What I am trying to do is have all the records that does not contain either N/A, S/O or xx and also have a filter on column 125 for the value "OUI".
VB:
Sub test()
Set ws1 = ThisWorkbook.Sheets("SOMMAIRE_EN_ALL")
Set ws2 = Workbooks("Fichier_central_2013_anglais_2_CLEAN").Sheets("DETAIL_CONCAT")
Set r = ws2.Range("A1:du4783")
[Code] .....
View 3 Replies
View Related
Jun 23, 2009
how to make this recorded macro work with more than the sheet it was recorded on. I need to work with the visible selections. But I'm having all kinds of problems trying to pick just the visible cells. Not having any luck with this project. I tried to included a test book but It keeps giving me an error.
View 4 Replies
View Related
Jan 25, 2010
I have a workbook in excel 2003 which I had been running the following macros (listed below). We recently upgraded to Excel 07, and neither are working. When I try to run them, the "debug" option highlights the following line in the sort macro "Range("A2:z" & lastcell).Sort key1:=.Columns(1)". This is driving me crazy, as the macros worked perfectly under the older version of Microsoft. Is there an issue with crossfunctionality between '03 and '07'.
Private Sub Worksheet_change(ByVal target As Excel.Range)
If target.Column = 1 Then
ThisRow = target.Row
startRow = 1
i = 1
Set ws = ActiveSheet
maxRow = Cells.SpecialCells(xlLastCell).Row
maxCol = Cells.SpecialCells(xlLastCell).Column
ActiveSheet.UsedRange.Interior.ColorIndex = xlNone
Do While i
View 9 Replies
View Related
May 25, 2014
I am now trying to create a excel macro to auto populate all the dates with reference to a start date and end date. The catch is that only working days are required in the range. My reference cells (start and end date) are in Sheet 1 while the destination cell range are in Sheet 2. The reason for creating a macro instead of a function is that the intervals between the start date and end date changes frequently (annual, semi-annual and quarterly) Best case scenario would be a button which I can just press after i input the dates to generate the range of dates in another sheet.
View 1 Replies
View Related
May 7, 2014
I needs a formula (not VBA) to calculate the required start date.
I have to do a job of 14 working hours and this job must be finished on 05-may-2014 13:00
My working week is from monday u/i friday and every day I work from 08:00-16:00
At what time do I have to start the job to get it done in time.
The formula should give this result: 01-may-2014 15:00
View 3 Replies
View Related
May 26, 2014
i am trying to create a excel macro to auto populate all the dates with reference to a start date and end date. The catch is that only working days are required in the range. My reference cells (start and end date) are in Sheet 1 while the destination cell range are in Sheet 2. The reason for creating a macro instead of a function is that the intervals between the start date and end date changes frequently (annual, semi-annual and quarterly) Best case scenario would be a button which I can just press after i input the dates to generate the range of dates in another sheet.
View 4 Replies
View Related
Mar 7, 2007
I'm trying to write a program for work. One sheet (whereiseverything.xls) will have a list of parts column E and where it is in the process column (k). Column E of this sheet will have multiple part numbers. (Sometimes duplicated.) I would like to figure out how to write a code to Auto filter (whereiseverything.xls) sheet and copy only one P/N from (whereiseverything.xls) column E onto another Workbook Worksheet (Commit status.xls) column. After that the sheet must copy all of the locations of that P/N from whereiseverything.xls column K into and under the P/N of the Commitstatus.xls.
It will continue to autofilter and copy from where is everything, the "one" p/n and all of its locations into another empty column of Commitstatus.xls until it no longer has part numbers to autofilter on whereiseverything. I am extremely green on VBA programming but here is my first attempt.
Windows("Where is everything commits .xls").Activate
Windows("whereiseverything[1].xxx").Activate
Columns("D:D").Select
Selection.AutoFilter
Windows("Where is everything commits .xls").Activate
Windows("whereiseverything[1].xxx").Activate
Selection.AutoFilter Field:=1, Criteria1:="7516113-905" \<--this Is one p/n
Columns("J:J").Select
Selection.Copy....................................
View 2 Replies
View Related
Dec 22, 2009
I am having trouble getting an autofilter to work in VBA which comes up as a 'syntax error' on this line.
Range("VehicleList").Offset(-1).AutoFilter 19,
View 9 Replies
View Related
Aug 3, 2007
I need to have users input a date range for a report and then use that to autofilter a query from a database.
I think I have it close, but I can't tell what I'm missing. I can see the InputBox dates if I put them into a cell. And the criteria operators come up correct in the Autofilter, but the value shows as Starting and Ending, so it's filtering out everything.
View 10 Replies
View Related
Aug 17, 2006
I have this script it does exactly as i want it to do, filter a table of date using two selected date in D3 and D4. There is only one problem: when i choose the dates and run the script it changes them around it around.
e.g
cell D3 = 01/11/2006
cell D4 = 01/12/2006
so it should just show all of november (11)
but D3 will filter using 11/01/2006
and D4 will use 12/01/2006
Sub DateFilter()
Range("a8:r323").AutoFilter Field:=1, Criteria1:=">=" & Range("D3").Value, Operator:=xlAnd, _
Criteria2:="<=" & Range("D4").Value
End Sub
View 7 Replies
View Related
Mar 31, 2007
I have a list of data that I'm sorting by date using an autofilter, but the way I have to set my criteria is by fiscal years and quarters; so I'm only concerned with the year and month parts of a date like 11/20/2006.
For example: all the dates in the list are in the standard US mm/dd/yyyy format, and for one filter I want to display only records with a date in the year 2005. I could use fixed dates starting with the first of the year and the last of the year, but I'm wondering if there is a better way.
I tried variations like this (but nothing worked).
varYear = 2005
Range("A1:K48").AutoFilter Field:=3, Operator:=xlFilterValues, Criteria1:="<=*" & varYear
View 3 Replies
View Related
May 22, 2014
I need a formula thet will look at the last date of the absence and calculate what would be the last working date in the given financial yaer.
Example
Abcence Start Date 21/08/13
Abcence Due End Date 04/11/14
Financial Year Start Date 01/07/13
Financial Year End Date 30/06/14
View 13 Replies
View Related
Dec 21, 2011
I have a fairly large database in excel 2010 that in being updated everyday by a employee. In column A there are a set of dates all in the same format 9/1/2011 what i would like to happen is that if there are any dates in column A then it cut out the row and paste it into Sheet1 (the data is stored in sheet2).
View 6 Replies
View Related
Nov 8, 2013
How to add current date till the end of the column until data exists.
i used
With Range("A2")
.Value = Date
.NumberFormat = "mm/dd/yy"
A1 will have the heading and from A2 till data exists it should show the current date .i used above code it gives date in A2 but doesn't copy to the remaining rows.
View 5 Replies
View Related
Mar 14, 2014
I have a sheet called "interface" which people can input the date in cell A2.
The autofilter in sheet"originaldata" will filter the data according to the date in cell A2 in sheet "interface"
However, when i input the date 01 Aug 2009, the filter will give me 08 Jan 2009
VB:
Sub Date_filter()
Dim Inputdate As Date
Sheets("interface").Activate
Inputdate = Format(Sheets("interface").Range("A2").Value, "dd mmm yyyy")
[Code] ....
View 1 Replies
View Related
Nov 28, 2011
Having a strange issue running an autofilter on a set of data - trying to isolate a particular date...
I have four variables :
wsDataSheet (Worksheet) specifies the sheet containing the datargAllRange (Range) specifies the range of data to be filteredinValueDateColumn (Integer) specifies the column in which the dates are held (entire column is Date formatted)dtDate (Date) is a date value specified by the user on the main sheetFor test purposes, I've filled the column with the same date (19/07/2011) and specified the same date on the main sheet (19/07/2011) - and checked that all variables are holding their expected values in the debugger.
But for some reason, when I run the code...
Code:
With wsDataSheet
.AutoFilterMode = False
.Range(rgAllRange.Address).AutoFilter Field:=inValueDateColumn, Criteria1:=dtDate
End With
The autofilter finds no matches??
Very puzzled as I've gone to great lengths to ensure the date formats are consistent.
View 3 Replies
View Related
May 3, 2012
In AA1 i input the date based on the lookup.
I want to filter Column 7 (Col G) to what ever is in AA1.
Say i had the date 02/05/2012. My filtered range should only be dated 02/05/2012 but its not filtering to those dates
Code:
With Sheets("UNPRODUCTIVE")
With .Range("AA1")
.Formula = "=IFERROR(LOOKUP(2,1/(TEMPLATE!S12:S40""""),TEMPLATE!B12:B40),"""")"
.Value = .Value
.NumberFormat = "DD/MM/YYYY"
End With
On Error Resume Next
.Range("A1:T1").AutoFilter Field:=7, Criteria1:=.Range("AA1").Value 'filter with only the dates the macro is run for
On Error GoTo 0
End With
View 4 Replies
View Related
Sep 3, 2007
I would like to include a filter in my macro that shows orders with current date, and sometimes current date minus one (yesterday). This is a monthly recurring task.
In the custom filter I tried: "equal to @Today" but that didn't work. Can someone tell me how I can solve the problem? Here's a snippet from my macro, filterne on something else Selection.AutoFilter Field:=21, Criteria1:=">=89" 'STCD_TO_TODAY
View 3 Replies
View Related
Feb 19, 2014
I have been struggling to find where my code is throwing up an error 1004 on the last line of the below code. I have a number of tables which will update automatically from Pivot tables on another sheet.
So the first part of the code is adding in the new column and then I want to autofill the date into the headers of the column which I thought the below would do, but I just don't understand why I keep getting the error. My data is dynamic as it will grow month by month which is why I am using R1C1 referencing.
Sheets("PNN Table").Cells(9, 16384).Select
ActiveCell.End(xlToLeft).Select
ActiveCell.Offset(0, -2).Select
Selection.AutoFill Destination:=Range(Selection, Selection.Offset(0, 1))
View 3 Replies
View Related
Dec 23, 2008
I have tried to record a macro and change it to what I need but so far I have not been able to make it work.
I would like to have a macro that will auto filter on colomn 1 in the following way.........BETWEEN >= Today -10days and Today.
View 2 Replies
View Related
Jan 10, 2012
creating 2 fields in my userform that the user can input 2 dates that would serve as the range to set the autofilter. So user inputs field1 = 11/01/2011 and then field2 = 01/31/2012.
I was previously using a month range in my userform, populating from the known months and allowing the user to select a range. Since our data is now spanning a new year, this is no longer possible as I cannot make the combobox range go from 11 - 1 (November to January)
VBA Userform - select months & Months between - Code Included
View 1 Replies
View Related
Aug 11, 2009
I have a similar issue, but it's with a date field. Every day, I go in and check the current day to show the current days data(on a Pivot table). Is there a way to modify this code so the AutoFilters update and "check" up to the current day?
View 2 Replies
View Related
Apr 4, 2014
I am using Excel 2003. I have attached a data file here. getting the values in Q3, R3 and S3.
Scenario:
Q1 has the number = 1. So I want the cell Q3 to return 2/11/2013 as that is the cell corresponding to the Item1 (value specified in P3) with the value 1(value specified in Q1) in the cell. Basically, I need the date corresponding to cell which has the value of Q1 for the value of P3.
Similarly, R2 must have the value 2/12/2013 and S3 must have the value 2/14/2013 returned.
View 10 Replies
View Related
Jan 26, 2013
We have arrival dates and departure dates for guests and would like to figure out the number of meals needed on a particular date.
Named ranges: NumGuests _ArrivalDate _DepartureDate _CheckInTime _CheckOutTime
Need number of breakfasts
Number of Lunches
Number of Dinners for a given day of the week.
So if a guest is here say Jan 25 arriving after 9am, staying 2 nights they will have Lunch and Dinner on the 25th, BLD on the 26th and BL on the 27th. Since by default most arrive after 9 (miss breakfast), we can eliminate the checkin time for the breakfast calc and make the first one for the next day.
There might be other guests staying through that time period. The ******* would like to know how many meals they will need to prepare for the week.
Windows XP, Excel 2010
View 5 Replies
View Related