Macro: Filter Database By Date
Dec 2, 2006
My problem is modifying existing macro code (see below) provided by Jim.
Sub WriteDetentionRegister()
Application. ScreenUpdating = False
ClearDetentionRegister
SortDataBase
AutoFilterDataBase1
Dim rDataRange As Range
Set rDataRange = DBase.Range("rDataBase"). CurrentRegion.Offset(1, 0)
rDataRange.Resize(rDataRange.Rows.Count - 1, rDataRange.Columns.Count - 2).Copy
DREG.Range("rdetreg").Offset(1, 0).PasteSpecial xlPasteValues
DREG.Activate
With Selection
.Sort Key1:=Range("rOffDate"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
End With
DREG.Range("rdetreg").Select
Application.CutCopyMode = False
End Sub
At present the writedetentionregister macro filters the database sheet for a positive balance (in column H) and pastes these records into another sheet called Detention register.
Is there a way of also getting the writedetention macro to count 7 days from the offence date (the E column of the database sheet) and ONLY on or after that date write that record to the Detention Register Sheet?
The workbook containing the database & the detention register sheets are enclosed.
View 9 Replies
ADVERTISEMENT
Mar 14, 2014
I have an excel sheet wherin there is a column that has the data where in the dates are displayed and many other columns.
I get this excel every Thursday so i want to filter this date column in such a way that it give me the data related to the date of the previous week only yet there is a catch here. When i say previous week i mean.
Suppose today is 03/14/14 then i want the data from 03/07/14 till today ie Last week friday to this week full( so cant use Current week option) and then paste it in a new sheet.
I tried the Record part but in that it is taking a hard coded value as i am selecting the date myself. I dont want to change the date manually every time.
this was the macro that was created
Code:
ActiveSheet.Range("$A$1:$BX$58").AutoFilter Field:=1, Operator:= _
xlFilterValues, Criteria2:=Array(1, "3/10/2014")
Range("A59").Select
ActiveCell.FormulaR1C1 = "=COUNT(R[-4]C:R[-1]C)"
Range("A60").Select
View 8 Replies
View Related
Aug 12, 2006
I am trying to create a macro that will import data from an external database; however, I want to be able to filter the data using input from the end user. The code will work fine if I do not use a variable (i.e. I type "31" to replace the second instance of "Reply" below).
Dim Reply As Integer
Reply = InputBox("Week Number", " Find Week")
ActiveWorkbook. Sheets("RawData").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=DataWarehouse;Description=DataWarehouse;UID=DataWarehouse;PWD=;APP=Microsoft® Query;WSID=WILLIAM;DATABASE=tmd" _
, Destination:=Sheets("RawData"). Range("A1"))
.CommandText = Array( _
"SELECT vOEEDownTime. …, " & Chr(13) & "" & Chr(10) & "FROM tmd.dbo.vO" _
, "EEDownTime vOEEDownTime" & Chr(13) & "" & Chr(10) & "WHERE (vOEEDownTime.downtimecode Is Not Null) And (vOEEDownTime.weekbucket = Reply)")
.Name = "Query from DataWarehouse"
View 6 Replies
View Related
Jun 11, 2008
I'm trying to get certain data from an export of a phone logging report for a call center. I have exported this data into an excel spreadsheet. I would now like to retrieve the following information from the sheet.
'Agent name, Date, time of Login, time of Logout (at end of day).'
I have coloured these fields in red for easy finding. I do not require anything else from this data, however, within this sheet there are multiple agent names and can span for over a month. All names and dates are required. I have attached the current sheet, and also what it will possibly look like once complete. I would prefer the whole process to be automated if possible.
View 2 Replies
View Related
Jun 27, 2014
I am having trouble setting conditional date filters for a column using a macro. I have two columns, A&B, each with dates in each cell. I want to filter column B to show dates that are less than or equal the corresponding cell in column A.
For example: A1=10th June 2014, B1=11th June 2014 --> The filter is set on column B, and B1 is excluded as it is not <= A1.
View 1 Replies
View Related
May 29, 2009
I do have an excel workbook containing two sheets:
Sheet1 contains a list of 30 criteria, every one with its own check box (TRUE/FALSE).
Sheet2 contains a database of items, which columns contain the 30 criteria mentioned above. (So sheet1.criteria1 can be the only value of sheet2.column1)
I am trying to program a macro, which can be assigned to kind of a "submit"-button in the first sheet. Its purpose should be to open a new third sheet and listing all the items from sheet2, which contain values checked=TRUE in sheet1.
View 10 Replies
View Related
Nov 6, 2011
I am struggling to get Excel Advanced Filter to work on a database, where not every field is populated. The problem I am experiencing is that Excel is treating a blank field as a criteria. When I run the Advanced Filter, any fields in the database that are not populated are filtered out of the results.
To try and illustrate the problem with a simple example: I have a database with two filter criteria: TYPE and CATEGORY. If I filter on type, it returns 100 results [correct]. If I filter on category, it returns 50 results, which is incorrect, as it should be 70. The reason it is returning an incorrect result is because it is treating the unpopulated/blank fields under TYPE as a criteria.
I have set up my criteria table with the below Boolean formulas: if the result of the formula is true (ie if it is blank), it returns "" and if it is false, it returns the selection.
=IF(ISBLANK(type),"",type)
Frustratingly, Excel Advanced Filter still treats the result of this formula as a criteria. So when I run the procedure, with only CATEGORY selected, all blank fields under the TYPE are filtered out of the results. The only way to get the Advanced Filter to produce the correct result is to delete the formula under TYPE from the criteria table - which of course defeats the object!
My intention is to incorporate the Advanced Filter into a VBA procedure, where the user will be able to select criteria under TYPE and CATEGORY from drop down menus.
I can think of only three possible solutions to the problem:
1. Ensure there are no blanks in the database (not really practical as it is not always possible to apply type or category)
2. Tweak the formula so that the Advanced Filter will not treat "" as a criteria
3. Write a VBA procedure, where the selections are written each time to the criteria table when the code is run (hoping to avoid this!)
View 9 Replies
View Related
Jun 25, 2008
When using a Pivot Table I regularly filter on known data specific to me i.e. WBS codes.
Column ‘A’ contains the WBS Codes which can be as many a 1000, however, I only need to filter out the 10 or so I require, and currently I uncheck all the records and manually scroll through the list to check the ones I require.
In order to speed things up I recorded a macro which works fine, however, If I need to check any new codes I would have to record the macro again, as I tried to edit the Macro and all it does is to un check all the other codes I don't need.
Is it possible to create a Macro that picks up a range of data that is then used to filter on. (i.e. only the records I require)
View 9 Replies
View Related
Dec 23, 2013
I just got into the world of PowerPivot, Excel 2013 and Pivot Tables and am in the process of creating a Dashboard which I will then be uploading to SharePoint 2013.
On top of page I added the new timeline filter which I've linked to my pivot charts. Now what I would like to do, is create an additional pivot chart which looks at whatever date range has been used in the timeline filter and subtract 5 years from that. So, when I select a date range of November 2013 - December 2013 in timeline filter, the additional pivot chart will show the details for November 2008 - December 2013. This is where I get stuck.
I'm using two SSAS cubes which I'm combining together in PowerPivot and then display in Pivot Tables and Pivot Charts.
View 1 Replies
View Related
Aug 6, 2013
Trying to use Excel Data List to create a database style report. IE. Originally blank sheet, which is only populated by data containing data matching "filters" input into cells ( say A1 & A2 )
I.e. A1 = Delivery week to be filtered by, and B1 Manufacturer Name
So if I type week "1" into A1 & Manufacturer "Microsoft" into A2, it will show a table only containing data Microsoft, Week 1, and associated data for those lines across the screen.
Week 1
Microsoft
PO number : Date Ordered: Address 1, 2 3 etc....
0011 01/01/13 Somewhere
0015 02/01/13 Anywhere
0213 05/01/13 Nowhere
I know this is much easier with a database, however my manager insists a database cannot be used, and it must be in a spreadsheet format !
View 3 Replies
View Related
May 25, 2012
Writing code to do the following:
Save advanced filter settings
Remove filter (or simply set to be 'select all'
Run other code (I have this piece of course)
Put filter back on with same selections chosen as when it was removed
(Need this becuase the code in the middle does not work properly when the data is filtered)
View 1 Replies
View Related
Apr 4, 2014
I have a formula that puts a date into a format I want to read date from a data base.
[Code] ..........
Output is correct = '17-03-2014' if the date is greater than or equals to the 10th but if its the 1st for example I get '1-03-2014' which is wrong as I need the zero to count the date properly. I tried a Left formula on a date field to bring in the first 2 digits but because its a date it returns for example 41 instead of 17 if its the 17th. I was going to do a Left(Text type of formula and place it into an if statement but that didnt work.
View 3 Replies
View Related
Mar 28, 2014
I have a database spreadsheet where it shows, the date and time a sale was made in 2 different columns, one for date, one for time (in Epoch format). What I need to do is convert this date/time to PST vs. the EST it's defaulted to.
View 1 Replies
View Related
Feb 17, 2014
i built a form and in the date section i have a date picker and once i fill the form out i have a button that saves all the data on another sheet like a database, what do i need to do to make it were it adds the date to the database itll add all the other data but cant seem to figure out how to make the date display
View 3 Replies
View Related
Jul 17, 2013
I have 2 sheet in MS Excel (MATTER & REPORT) . Database included at sheet MATTER. Report will be seen on sheet REPORT based on entry date. What formula used to produce report automatically.
View 4 Replies
View Related
Mar 20, 2014
I'm trying to filter 2 date columns to include only data containing dates within 3 months of today's date.
I see there is a data filter option for "next quarter" but not 100% sure if this covers the quarter from today's date?
View 3 Replies
View Related
Mar 31, 2004
I am currently trying to create a database of products for my company. For each product I would like to include an image associated with it. I then want to have on another sheet a place where the user will click an error and be able to cycle through the products. As tehy cycle the associated image will pop up.
What I need to understand is after importing the image into excel, how do I associate that image to a cell so I can reference it in another sheet of the database. I am not concerned with how large the database will get, my pictures are quite small.
View 4 Replies
View Related
Nov 7, 2008
I'm trying to lookup a database named database and return a time in column A, based on criteria in cells a1 and b1 on another sheet, A1 would contain a number and B1 would contain a day from mon-fri
eg of Database
A B C D E F G
10:00 5000 Mon Tues
11:00 5000 Wed Thur Fri
and so on
if a1= 5000 & b1=Wed
how can I return 11:00
I have tried index and match =index(a:a,match(a1&b1,b:b&e:e,0))
View 9 Replies
View Related
Jun 1, 2014
I have my ms access and ms excel which is connected each other .
=> now in my ms access have a table name (tblMonth) has columns (year,MonthNum,StartDate,EndDate)
HERE: sample in january(1) and feb(2)
YearMonthNum StartDate EndDate
2014 130/12/201305/01/2014
2014 106/01/201412/01/2014
2014 1 13/01/201419/01/2014
2014 120/01/201426/01/2014
2014 127/01/201402/02/2014
2014 203/02/201409/02/2014
2014 2 10/02/2014 16/02/2014
2014 217/02/201423/02/2014
2014 224/02/201402/03/2014
=> and for my ms excel has its columns (year,month,date) in this if i input the date that is base in the database range from StartDate TO its EndDate will automatically put the month and year which base also in my database (year,MonthNum)
HERE:
A1 B1 C1
Year Month Date
A2=2014 B2=January C2=01/01/2014
View 3 Replies
View Related
Jun 21, 2006
By adapting a worksheet macro obtained previously via Ozgrid, I built a workbook that dynamically produces a database, in a worksheet titled “NumLtrWBS DB”, based on all possible combinations of what is listed in column A of three 3 worksheets titled: “ Num”, “Ltr” and “WBS, respectively. The macro, named “NumLtrWBS", works wonderfully, until I add a row at the top of each list to contain a column header. The unchanged macro includes the column headers in the “produced” database. When I change the macro by altering the variable definitions to begin at A2 rather than A1, it still includes the column headers in the “produced” database. How should I change the macro so it doesn’t “produce” the column headers in the database worksheet?
View 4 Replies
View Related
Jan 29, 2014
I have sql queries in spreadsheet column and which needs to run against Db2 database daily and then update the result back to spreadsheet. This is tedious process and could there be a way to create a a macro using VB which performs the following?
1. connect to db2 database
2. take the sql query one at a time from every row and then run against database
3. Obtain the result and then update it back to last column of the spreadsheet.
View 3 Replies
View Related
May 15, 2013
Basically I want to set up a workbook, which will have a sheet called "Database" and then sheet1.
I want to use sheet1 as a "add to database" sheet, where users will simply dump in some data into sheet1 and the marco will format it so it matches the headers of the data base and then it will add/update the database sheet with the info (and new info if its new) from sheet1.
Here it is in pictures.
This is basically what the database sheet will look like (but much much much more rows of data)
As you can see this is a job database with some columns for POD, Connote, etc.
This is what the update sheet1 will look like when someone dumps some new data in (I can easily write a macro that formats it to match the database)
So basically I want the VBA to merge this sheet1 data into the database sheet, as you can see, there is simply a few 1's added to various columns for "Car Dudes" and "Robin Manufactures" but "Jimmys Lollies" row is completely new and not in the database.
So the marco would basically match up either the Job number or the HB number of the rows in sheet1 and if there is a match in the database sheet it will update the cells data, and if there is no match it will add the row to the database sheet.
The issue is the data in sheet1 might not be fully complete all the time, it might only have a job number and not a HB number, it might not have a client name or whatever. Basically the data users dump into sheet1 will come from many different reports, many different sources, what I'm trying to do is essentially merge all this data into a common formatted database sheet, for further working.
So in a nut shell, a macro to:
1. Match Job/HB numbers in sheet1 with rows already in database sheet and update row accordingly with any new data.
2. Add any new Job/HB rows from sheet1 into database.
View 4 Replies
View Related
Jun 21, 2007
know the code to export a file to data base?
View 6 Replies
View Related
Oct 17, 2013
I've used a countifs, but I'm having trouble doing a sum in a similar way. I have 2 databases and I will try to explain below. I need the to sum the values of database 1 if the second database is >= 20. So the value I would expect on this example would be 900. I would also like to be able to highlight which ones are elliminated. Such as coloring the text red.
Database 1
Eric 100
Jenny 200
Gina 300
Doug 400
Database 2
Eric 18
Jenny 20
Gina 34
Doug 55
View 5 Replies
View Related
Feb 22, 2014
need macros :
Copy From Sheets ("PO")
Copy D7 & H7
Copy C11 : H25 (Only Active Cells)
Paste To Sheets ("Sheet1")
D7 & H7 = Column A & B
C11 : H25 = Column C, D, E, G, H
database.xlsm
View 4 Replies
View Related
Feb 26, 2009
I have created an Excel sheet that retrieves data from a ODBC source. I have created a macro using macro recorder to refresh the data by re-connecting to the database. However, the connection requires a password prompt and when the macro is run, you are still required to enter the password.
Is there anyway to make the macro so that the password is automatically entered and the user will just have to press a button to fully run the query update?
View 2 Replies
View Related
Nov 21, 2006
I am exporting data from a database and will want to split up the information into separate worksheets & eventually into separate workbooks.
What I am looking for is a macro code that will automate the cut/paste of information onto other worksheets. I know I can record the macro but the problem is the data sets vary in size each quarter.
What I need is a macro code that looks for a particular phrase and when found it automatically puts all rows undernear (until phrase appears again)on a new worksheet....make sense? The phrase might appear twice or 50 times, so each time it is found the data following will cut/paste.
View 9 Replies
View Related
Aug 1, 2014
Following macro code is for copying Excel Invoice Data to Excel Database. Also cleans the specified cells after copying. Its working Perfectly.
But there are some issues that should be solved.
Problem 1: It copies empty cells(""), formula based cells and blank drop-down list.
Problem 2: After copying it cleans formulas too. Formulas must be remain their.
View 2 Replies
View Related
Sep 7, 2006
I would like to know how to migrate an Access database to a spreadsheet, I do not mean Exporting.
More specifically, the migration is conditional. The spreadsheet only needs a few fields from specific tables in the database. It is basically a data dump, however, the magnitude of the amount of information that I will be handling will be far too time consuming and not within the scope of the budget to do this all by-- Exporting-->Copy-->Paste method.
Also, changes often need to be made "The night before..." so the macro will need to be able to ran possibly a number of times to update the additional data or changes in data.
In my research I have found a few snipets of VBA code from the MSDN website as well as some other websites, however none of it seems to be consistent with one another and ultimately results in it not working.
Is this possible?
View 9 Replies
View Related
May 18, 2012
I'm working on an Excel based product. As part of the security process I would like to require the user to enter a product id key into excel. Then the spreadsheet would compare the entered value to some kind of online database to verify the id key is valid. Finally, the spreadsheet would update the online database so that the id key is no longer functional. How easy is this to do?
I know verifying that the id key is valid is fairly simple.
Here is my biggest issue: How to get Excel to update the database and of course what form would this database take. Maybe its a table on a webpage, or google docs. Again the issue is how would I be able to update the table.
View 1 Replies
View Related