I have a set of data that I need to sort and filter and create pivot tables with 2-3 times per week. Example data sheet attached (confidential data removed). I will insert the code that I am using for reference. The issue is that when the data is filtered for 'Approved Timesheets' I need the filter to be based on 2 criteria; If myBaseRow.Cells.Item(1, 21) <> "Approved" Then If myBaseRow.Cells.Item(1, 44) <=StartDate And myBaseRow.Cells.Item(1, 44) >=EndDate Then
The first If statement works fine, but the second appears to be ignored?? I have tried to colour this part of the code blue to make it easily visible.
Private Function PTSubtotals(ByRef PTField As PivotField)
PTField.Subtotals = _
Array(False, False, False, False, False, False, False, False, False, False, False, False)
' Timesheets Macro
' Timesheet Filter 4/22/2008 by Richard Francis
Dim myWorkBook As Workbook
Dim myBaseWorkSheet As Worksheet
Dim myBaseRange As Range
Dim myBaseRow As Range
Dim RowsCounter As Long
Dim StartDate As Date
Dim EndDate As Date
StartDate = Format(Date, "mm/dd/yyyy")
EndDate = Format(Date, "mm/dd/yyyy")
On Error Resume Next
StartDate = Application.InputBox("Enter start date", Type:=2)
On Error Goto 0
If StartDate > 0 Then.................................
I have a macro I am using that uses several date filters. There are filters for the previous month, previous 6 months, previous year, all dates in the future, etc.
Every month I have to edit the macro and change the dates in the macro so it remains accurate. Is there any way I can modify the macro so that the dates are stored in a cell within the workbook and not in the macro?
What I would like is to type the date ranges in a sheet within the workbook and have the macro look to those cells for the date filter instead of typing in exact date ranges within the macro. This way the actual macro code does not need to be modified every month. I would like to only have to change cells within the worksheet and not touch the macro code.
I do not know VB coding but is in need of help on data filtering/matching. I have 2 very big excel workbooks with a few thousand lines and am trying to do some filtering/matching. Example below.
The two workbooks I have contains same data in column A and also column D from the first data set is the same as column B in the 2nd data set. I am trying to add column C and D from the 2nd data set to the 1st data set and need to make sure they match up to column D from 1st set and B from 2nd set. It is quite strenuous to do this manually,
A1 2 3 100A A1 2 3 100B A1 2 3 100C A1 2 3 100D
A1 100A AA BA A1 100B AB BB A1 100C AC BC A1 100D AD BD
What would be the code for this? I want use the code for bigger data?. Also if you have a file which is 100 lines long and your macro does a series of steps for that file. Then you have another file and you want the same steps done but it is 500 lines long. How would you write a macro thatrun the steps taking in the last line and not just a 100 lines.
I have a large worksheet in drive C: called 'hits.csv' that has manufacturer part numbers in column G and column L.
I need macro code to find all rows in the worksheet where the part number in each cell in column G is exactly the same as the part number on the same row in the corresponding cell in column L. The macro should then delete/remove all rows where there is no exact match.
Note: The part number in every cell in column G is the only thing that is in each cell in that column. However just to warn you that the part number in every cell in column L is at the beginning of each cell, followed by a space and then a description of the part.
Once it has done the above, I would also like this macro code to open a worksheet called 'partnumbers.csv' in drive C:. It should then compare the part numbers in column A of this file with the part numbers in the above worksheet ('hits.csv'). The cells in Column D of the file 'partnumbers.csv' all contains a price. Where the macro finds an exact match on the part numbers in these 2 files, it should copy the price from the cell in column D in the file 'partnumbers.csv', into Column K of the other file, 'hits.csv' where the match exists.
the macro mentioned below has been assigned to a combo-box form. I have 2 different datasets in the same sheet, they have the same headers (but named differently, myhead and myhead1) and the same adv filter criteria range (named as "dcrit") is applicable to both datasets. So, if an item is selected from the combo-box, both the datasets should get filtered according to same criteria. how i can combine the 2 IF LOOPS mentioned in the code?
Sub myfilt() Application. ScreenUpdating = False If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData If Not (Range("indsignal")) Or Not (Range("countsignal")) Then Range(Range("myhead"), Range("myhead").Offset(1, 0).End(xlDown)).AdvancedFilter _ Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False End If If Not (Range("indsignal")) Or Not (Range("countsignal")) Then Range(Range("myhead1"), Range("myhead1").Offset(1, 0).End(xlDown)).AdvancedFilter _ Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False End If Application.CutCopyMode = False Application.ScreenUpdating = True
I've taken data from a fixed-length text file and the records are identified using the first two characters on each line of the text file. I've managed to identify these in each row with other bits of code so that was fine.
Now, I have 56 string variables (identifying my record types), which I'm assigning into an array. Then, I want to go through each variable in the array, performing the same action by way of a For Next Loop where, by taking this particular RecIDNo (see my code) string variable I will get the code to copy/paste the data into the relevant worksheet (where later on I will apply a text to columns using another array). But first, this set must work before I can do that! To avoid confusion, note that the record types i.e. 01 through to 56, will be filtered, then copied into the corresponding worksheet with the same number.
The problem I'm getting is the autofilter I'm applying, then the array I'm trying to reference (to avoid repetitive coding!) doesn't work as the code doesn't compile (I've not worked a lot with Arrays but I'm learning all the time!)
Option Base 1 Sub test() 'The array is declared here: Dim RecIDNo(56) As String 'The arrays are assigned the string variables below: RecIDNo(1) = "01" .... RecIDNo(56) = "56" 'This worksheet contains my data: Sheets("DATA").Select
For RecIDNo(1 To 56) '<--I THINK THIS IS WHERE I'M GOING WRONG!! 'Filter and select arrays:................
I'm trying to look up a value in Analytics Data searchin for the date in B9 to B & rader.
I get error messages, because i can't find the dates. But I'm sure I have defined the ranges correct. The code works in another workbook with the difference that the table with the variables I'm trying to lookup are in the same sheet as the where I want to place them.
Private Sub Upd1_Click() Dim rader As Double
Dim lookrng As range Dim updvalue0 As Double Dim updvalue1 As Double Dim updvalue2 As Double Dim updvalue3 As Double Dim updvalue4 As Double Dim updvalue5 As Double .........
I found a great bit of Advanced Filter code that works great, and fixed a problem of clearing a cell breaking the filter.
But if I want to increase the criteria from 1 row to 2, so you can start to include And , Or operations, it breaks the filter. Even an attempt at a manual one fails, until you put the criteria range back down to one row, then it's fine again.
I've tried changing the Target Row to >2 but that didn't work. how to make the criteria range bigger, and no problems of breakage if you clear the cells? It makes for a very useful automated Advanced Filter.
Here's the code :
Database = the named area of raw data. DATA is the name of the raw data worksheet The criteria range should be AZ1:BC3, but of course royally breaks it...
The code as it stands allows me to push a button and it immediately picks up on a meeting category and date of meeting, then sends emails to those that are supposed to attend based on a date that is within 7 days from the current date of pressing that button. HOWEVER; it seems to still send the email when the date has passed...is there a line I can put in this code to make it so that every date that has already passed will be discounted from future emails?
I have a UserForm that is designed to allow the user to filter dates on various columns. There are three comboBoxes on this sheet that are populated by linking to cells on a Control worksheet using RowSource in the Properties window. catCombo is the column to filter, dateCombo and endCombo are the two dates to filter between.
I have come up with the following code to activate filters, but there are problems (which I'll tell you about in a sec!):
I've tried IF/AND, MEDIAN and whatnot, but cannot get this to work:
On Sheet1 I have a list of records with date in column C and a text string such as 'Urgent' or 'Nice To Have' in column H. There are hundreds of these records.
On Sheet2, I want a count of rows that have e.g. 'Urgent' -text string in column H. However, I only want the row added to the count if the date in Sheet1/Column C matches between two dates defined in Sheet2.
I want to create an advanced filter criteria along the lines of =AND(col1>begindate,col1<endate)
where 'col1' is the title in the cells at the head of the appropriate columns in the data range (B1), criteria range(F1) and extract area range (I1), and 'begindate' and 'enddate' are named single cells.
With the attached spreadsheet what I am trying to do is create a userform sheet that I can use to look up a specific date within the spreadseet. First of all I somehow need to populate the drop down box with all the dates that are located in the sheet. From there I would like a macro to go through my workbork and find all the selected dates and bring back the "Task #" and Site Name associated with the dates
For example if I put Mon 09 Jun in the macro will bring back Site one - Task 1 Site three - Task 2 Site two - Task 1
When clicking on the sorting button of filtered data near the top of a field, I can select different things to show or not show. In a date field, it starts to arrange things by year, which can be expanded to months, which can further expand to show individual days. All well and good.
But many of my dates do not show up in the year categories. They are instead shown below the years as individual dates. Furthermore, sorting the date field in question is imperfect for these dates. Here is an example where some dates from april are jammed inbetween others:
I have a sheet with data imported of another software. In the column "G" are all the dates, and the problem is how can i change the format, because, some of them are "mm/dd/yyyy" and the rest are "mm/dd/yyyy".
Is there a way to change it to the same format? maybe there are some dates like "11/02/2007" that are "02/11/2007" (i don't know how change it with code), and others that the difference between formats is logically clear. I want to get the format "dd/mm/yyyy".
After this i want to apply a filter between two dates, for example, (in dd/mm/yyyy) from01/05/2007 to 30/08/2007.
I've tried different ways, but i'm not able to transform the format of the dates to the same format, although i've read your help and other posts that talk about this.
I have a excel sheet auto generated by a process in which there are 4 columns and 150 Rows. One column has dates data in DD-MMM-YYYY (15-May-2007) format..but the datatype of that cell is not Date. When I click on any date let say I selected 24-Mar-2007 in formula bar instead of displaying 3/24/2007 it displays as it is 24-Mar-2007.
But when i double click on this cell it shift to right alignment and display date format 3/24/2007 in formula bar. I have to create a formula using which I can see only some rows of define date range. Means if i define range in two cells 01-Jan-2007 and 01-Jun-2007. The sheet will display only rows having this criteria. But due to this datatype problem before putting the criteria I have to double click each of the row to convert it to Date. RightClick Format cells option is also not help full in this.
I have mutliple non-contiguous columns that are SUPPOSED to contain dates. If the particular item for that coulmn doesn't require a date then "waived" is typed; others may be blank. I want to apply a filter that will tell me if any one of the columns YEAR is older than "2004". I'm really bad at formulas to bare with me.
I inserted the following formula: =IF(OR(YEAR(N6)<=2004,YEAR(V6)<=2004,YEAR(X6)<=2004,YEAR(AB6)<=2004,YEAR(AD6)<=2004,YEAR(AF6)<=2004,YEAR(AI6)<=2004),"EXPIRED","GOOD")
The problem is that if the cell is blank or if contains "waived" it either produces "#value!" or it reports "True" when it is actually "False". I'm not sharp enough to know how to account for those two conditions in my formula.
I have a pivot table with a date variable in a row. I would like to filter these to only show dates equal to, or older than a date value in a cell, when opening the workbook. The max date value is based on the today() function minus 12 months.