How To Compare Two Sets Of Dates Against One Another In VBA
Jun 11, 2014
I am trying to figure out how to compare two sets of dates against one another in vba. The data is spread over eight columns. I need to be able to find the smallest date in the first four columns and then compare it to the smallest date in the other four columns, then go to the next smallest and so on.
View 4 Replies
ADVERTISEMENT
Nov 10, 2013
I have 2 sets of data/array/range. Each set consists of 2 columns with a large number of rows.
I want to compare my 2nd data to a master data. And list if anything is different in 2nd set of data from master set in column A than highlight the difference or copy the value to another place.
Also want to compare the 2nd column if column A was same and consider both column A and column B for that associated row different if column B is different.
The trouble for me comes in because the list is never alphabetical (sort doesnt work cause of funky naming) and never of the same size.
Attached is a photo of an example for maybe an clearer understanding. Also attached an example excel sheet I tried it within excel but cant seem to figure out how to look also for the 2nd column, so im trying to avoid the within excel route and go using vba ...
T3OCcxw.jpg
example.xlsx
I attempted it with a very basic code thats not working =/ just cant seem to figure how to code to get the desired result
VB:
Sub matchdiff()
Dim cell As Range
Dim found As Range
[Code].....
View 1 Replies
View Related
Sep 5, 2007
I am a absolute newbie to VBA, I've got 2 timetables, they show deliveries for different countries. I need to make my code as DYNAMIC as I can. TableCustomer shows the customer's name, country and their opening times, Saturday - Friday, it uses 1s and 0s to determine if they are open or closed, 1 = open, 0 = closed, so the headers are: Customer Name, Country, Saturday, Sunday, Monday, Tuesday, Wednesday etc.
TableCompany shows the days of deliveries made to each country by the company, using 1s and 0s, 1 = Deliver, 0 = Don't deliver. The headers are Country, Saturday, Sunday, Monday, Tuesday, Wednesday etc. An example here is that, if in TableCustomer, the customer is opened(1) on a Saturday, but in TableCompany, the company does not deliver(0) to that country on the Saturday, change that 1 into a 0 in TableCustomer. But if the Customer is closed(0) on the Saturday, then don't change the value 0, because the company will not be able to deliver to them anyway, even if they can deliver to that country on that day.
View 3 Replies
View Related
May 26, 2014
In my attachment I am trying to identify rows within Table 2 that do not fit in with Table 1. For example in Table 2, Row 16 has a Start Date of 17.11.2010 and an End Date of 13.11.2011 for ID number 151. This record has to be shown as "OK" because it fits into the date range of Row 103 of Table 1 i.e. Table 1 Row 103 has a Start Date of 01.01.2010 and an End Date of 28.02.2013 for ID 15. In other words the Start Date of Table 2 Row 16 is GE the Start date of Table 1 Row 103, and the End Date of Table 2 Row 16 is LE the End Date of the same Row 103 of Table 1, therefore this reocrd is OK.
Row 14 of Table 2 needs to be shown as "NOT OK" because it has a Start Date of 12.01.2013 and an End Date of 31.03.2013 for ID 15 and this doesn't fit any date range of any Row in Table 1 for ID 15.
View 2 Replies
View Related
Jan 17, 2014
I have 3 different series: S, J, and D. Each series has a list of different dates, and I need to plot the results for each date, while comparing the 3 series. I have created 3 different charts to display the results for each series - list of dates. However, I'd really like to chart all 3 series on one chart, so that you can see how the 3 compare.
I believe my obstacle is that the list of dates are not consistent between the 3. I tried to get around this by creating one table with all the dates, and leaving blanks where necessary (on Sheet 2). However, this created a problem because the blanks showed on the charts as 0s.
View 5 Replies
View Related
Jun 4, 2009
I'm new here. I've searched these forums in the past for help, but never had to post, i've always been able to find something by searching. However, this time I couldn't find anything that addressed my specific need so I figured it'd be worth a shot.
Alright, I have two sets of dates, and i'm trying to set up a formular that calculates the numbers of days from the first date range that overlap/fall within the second date range.
For example:
In A3 type "1/1/2006"
In B3 type "1/1/2007"
In C1 type "6/30/2005"
In C2 type "6/30/2006"
Now, in C3 i'd like to insert a forumla that tells me how many days in the date range of 1/1/2006-1/1/2007 fall in the date range of 6/30/2005-6/30/2006. Basically for this is should be half the year, however many days that is.
Is this possible with a formula?
View 10 Replies
View Related
Jun 30, 2009
i got 2 sets of data, but the dates are not correlated
For e.g.
3/18/199610 3/18/199613.5
3/19/199610.1253/19/199614
3/20/199610.1253/22/199614
3/21/199610.25 3/25/199614.0625
3/22/199610.25 3/26/199613.25
3/25/199610.25 3/27/199613.1875
3/27/199610.25 3/28/199613.125
3/28/199610.25 3/29/199613.5
3/29/199610.25 4/2/199613.625
4/1/199610.3754/4/199613.8125
as u can see the dates jump here and there
is there anyway that i can sort it out so that the dates would correlate to each other on the same rows?
if its possible, i have like 16 sets of data to correlate, how do i do it?
View 10 Replies
View Related
Jul 2, 2014
I am putting together a simple table to display current week's data vs previous weeks. The current week's data is drawn from a status chart which changes frequently. The constant change is fine for 'Current' as I only want the current data displayed.
The problem I am having is calculating the number of late jobs that existed during the previous week.
The status log has a due date which is compared to the current date to determine 'on time' status for the current week.
Due dates are reissued regularly so I can't use
=COUNTIF(RANGE,WEEKNUM(NOW()-1)) to return data about last week from my status chart.
I have available a 'Movement Log' (in the workbook but a separate worksheet) which tracks the changes in the due date field, but I'm not sure how to integrate that data to calculate the # of jobs that were running late from the last week.
My thought is that I need to perform a count of the # of late based on a comparison of 'due date' to 'date of the last day of last week' with a way to insert the "old due date" from the movement log to replace what is shown in the status log if necessary.
Movement Log.JPG
Status Chart.JPG
View 1 Replies
View Related
Oct 5, 2009
I have tried nested ifs and vlookup to compare two sets of data and change the first set of data if it is than the first. But leave it alone if it either is the same or does not exist in the new set of data. It sometimes seems to work but i find it is not consistant. It looks simple but i think i am missing something.
if column A has identifiers and column B has results then it should work if the identifiers in column C are found in column A and it looks to see if column B and D are the same, then change B if different but leave it if either it is the same or not there.
A
code1
B
36
C
code1
D 33
View 9 Replies
View Related
Apr 10, 2008
Below is a series of sets. Column A is the set number. I need a macro that will insert a row between sets and then put a border around each set. In my spreadsheet the sets are from A1:C500. Sometimes the sets are only 1 row, sometimes multiple rows. It looks like I will be doing one of these sheets every week. So far I have been doing it manually, but a macro sure would save some time.
View 13 Replies
View Related
Jul 16, 2007
Using Excel 2003 on XP.
In Workbook1 I have a list of users with a leave start date in column N and a leave end date in column O.
In Workbook2 some of these of users appear with a payment start date in column C and a payment end date in column D.
I need to find out if the any or all of the payment period for these users in Workbook2 falls within the date ranges of their leave in Workbook1. If not, I need to ignore (or delete) the payment record in Workbook2 for that user.
Is this possible using VBA? Mind you, I'm stuck either way as I simply have no idea about how to approach this (possibly ... would first need to work out how to identify if the dates cross and then perform a lookup ...?)
View 11 Replies
View Related
Jan 29, 2010
I have two columns (G&H), one has expected date, and one has actual delivery date. The line amounts vary from 2500 to 8000, I need to calculate if column H is greater than column G for each line, if it is not then that line can be deleted.
View 4 Replies
View Related
Oct 30, 2009
I have the following date formatted strings in two Excel cells "17/12/2009" & "19/12/2013".
Now I try to run the following code on these cells:
If Range("B" & i).Value < Range("B" & j).Value Then
But it does not seem to work, as the dates are compared incorrectly.
Any clue how to bring these dates in a VBA readable format?
View 9 Replies
View Related
Jul 17, 2009
I am trying to compare the difference between to dates (a person dob and the date of an activity they have carried out and then output the age of the person when this activity was done:
for example:
activity date: 08/01/2008
dob: 05/12/2007
View 14 Replies
View Related
Jun 8, 2006
I need to compare dates in excel (VBA programming). How can I do to Compare two dates. If I wanna know the difference between to dates (days, moths and years)
View 2 Replies
View Related
Feb 15, 2008
I am getting a type mismatch error ehen comparing 2 dates. I tried entering all date formatting but it still throws the same error... here is my code. i have highlighted in bold where I get the error. the Error it throws is Run Time Error 13. Type Mismatch Error. I am using office excel 2003 SP3
Dim siebApp As SiebelWebApplication
Dim siebBusObj As SiebelBusObject
Dim revBC As SiebelBusComp
Dim isRecord As Boolean
Dim sRep As String
Dim sCompany As String
Dim sLocation As String
Dim sStep As String
Dim sProb As String
Dim sDate As String
Dim RetDate As Date
Dim CurDate As Date
Const DateCol = 9
CurDate = Now()
RetDate = Sheets("Users"). Cells(DateCol)
r = Sheets("Users").Cells(65536, 1).End(xlUp).Row 'Get next blank row
Sheets("Users").Cells(r, DateCol) = CurDate
'Create The Siebel WebApplication Object
Set siebWebApp = CreateObject("TWSiebel.SiebelWebApplication.1")...........................
View 5 Replies
View Related
Mar 10, 2014
My Process goes like this: We receive work in the excel sheet and in the column K(Period will be in YYYYMMDD)
First I want macros by which I can change YYYYMMDD TO MMDDYY.
then
It should compare column J and column K.
see the below example.
Period date (column K) Product end date (column L)
Column J column K
20131031 10/31/2013 = If column J & K dates are equal then "No action required"
20131031 7/31/2013 = If column J is higher then column K dates then "Action required"
20130930 11/2/2013 = If column J is lesser then column K dates then "No action required."
I need comments in column Q.
View 1 Replies
View Related
Dec 11, 2013
I have two enormous lists of dates. How do I automatically compare them to ensure the date on one comes after the date on the other one?
They're formatted as dates. Christmas Day 2000 (UK) did say 25/12/2000, and then when I reformatted it it automatically changed to 25 Dec 2000, and so on.
View 4 Replies
View Related
Mar 19, 2014
I've been trying for a few time to make a sub, on VBA, that writes, in a specific column, " " or 1 depending on the date that is inserted. The thing I can't quite do is:
1 - I have a sheet where the different projects of a company are stored (name, starting date, ending date and person responsible) and where new projects can be added from a UserForm
2 - I also have another sheet were costs from the projects are stored (one line with cost 1 from project 1, another with cost 2 also from project 1 and cost 3 from project 2, etc) and where I can also add a new cost with another UserForm (this cost as also a date that is added, to when it happened)
3 - What I need to do is, on the costs' sheet I need to create a sub that in the last column adds me 1 if the date of the cost added is not a date between the starting and ending date of the project that it corresponds.
View 1 Replies
View Related
Dec 22, 2013
Currently I am working on a Userform based Macro that reads date and time from user and compares it with the date and time present in a cell in excel sheet(in mm/dd/yy hh:mm format). If the date and time value entered in both places matches then it will fill green colour in the cell.
I tried to convert the date present in excel sheet into a string using Cstr but it is not working. I have attached the code below for your reference.
Dim lr As Long, i As Long
lr = Sheet5.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To lr
If Cells(i, "D") = "FIT" Then
If Left(Sheet5.Cells(i, 14), 1) = "M" Then
[code].....
View 3 Replies
View Related
Jun 27, 2006
I am trying to set up a spreadsheet to track certification expiration dates and things of that nature at my volunteer fire department. At my career job, we use specialty software like Firehouse, but that is way too expensive so I must settle for Excel..or maybe Access.
Basically, I need a formula that will look at todays date and compare it to the date in a given cell and then somehow differentiate thise which are expiring at a given intercal.
For example, if someones EMT was expiring in 6 months it would turn yellow, then at 3 months turn blue, then red at 1 month then black if it expires.
It don't necessarily have to be just like that, just some way to differentiate depending on the how close to expiration it is.
View 3 Replies
View Related
Oct 25, 2007
I need to compare dates from two workbooks. The dates are not entered in the same format. In order to compare them I store them in Date variables.
However, some dates entered do not have a standard date format (for example, day is missing) and I get an error when I try to store them in a Date variable.
The solution I thought out (most likely a bad one) was to temporarily re-dim the variable from Date to String when an error occured. The macro would then be able to store the incomplete date and do the comparison.
So, basically, the variable would be dim'ed once as a Date, then possibly dim'ed a second time as a String, and if this occurs, then it would be dim'ed back to a Date once the erroneous date would have been treated as a String.
My problem is that it doesn't appear to work if I use the dim statement because of "duplicate declaration in current scope". Is there a way to re-dim a variable as something else within the same macro?
View 6 Replies
View Related
Apr 11, 2008
Battling through a problem, but would like to get some feedback on some failing code.
basicly created a bunch of macros to get 2 columns. One has last months dates, and the other has the new ones.
I want it to check if the date in columnH is greater then columnJ then update (i have vlookups to get this info with offsets). You see if there is no result on columnH it means it does not add a date.
heres the code that i have. The error is that i am using an invalid statement in the case ( i suspect the >=)
View 9 Replies
View Related
Dec 11, 2013
I have 2 columns directly next to each other each containing dates.
Example 1:
F2 = 5/23/13
G2 = 5/23/14
Example 2:
F3 = 6/6/13
G3 = 4/11/14
I wanted to do a conditional formatting that would highlight the cell in
column G if the Month/Day doesn't match the Month/Day in column F
Is there a way to do this with Excel only looking at the Day/Month and ignoring the year??
View 3 Replies
View Related
Feb 5, 2009
I have several old spreadsheets that contain patient information. Except for names, dates of birth, and dates of surgery there is nothing consistent about them. Not only that, the old spreadsheets were in various stages of compiliation and recompilation when they were abandoned. So now there are multiple duplications of old names added to lists of new names spread across multiple spreadsheets. I have to identify names that are not already in my database and add them.
I have a formula that I found on the internet that I can use to check if a patient’s last name in an old spreadsheet is one that already appears in my main database. In my attached example the formula looks like this:
View 3 Replies
View Related
Mar 14, 2012
I am fitting 2 sets of data to match eachother. I want to have as much data as possible but only for the same dates of each dataset.
I have 4 coloumns.
Dataset 1: A is date B is data
Dataset 2: C is date D is data
I want to compare A vs B one row at a time. If they are not similar it should delete and shift up the values in A+B or C+D according to the lowest value (date) of A vs B.
Remember that if the macro just deleted and shifted up it should compare the same (undeleted) value against the new value that just shifted up in the other coloumn.
View 2 Replies
View Related
Nov 24, 2007
I have a column of dates (B2:B1500) that I want to compare to a single date (A1).
If the dates in Column B are older than the date in A1 I want to delete the entire row.
View 3 Replies
View Related
Apr 18, 2013
I'm using Excel 2003.
I have a Userform where you can enter a date and select a comparison operator from a combo box. Any one of these (= < <= > >= <>)
In VBA I then load a range into a dictionary object and then loop thru it to compare the dates in the dictionary to the date selected in the userform but I can't get the dates to compare correctly. I think it has something to do with the Evaluate function comparing the dates as strings but I'm not really sure.
VB:
For Each strKey In dictValid.Keys()
If Not Evaluate(CDate(dictValid(strKey)) & cboDteOperator.Value & CDate(txtDteSel.Value)) Then
View 3 Replies
View Related
Apr 20, 2006
I have a spreadsheet that captures task start and end dates similar to project. It currently calculates Networkdays correctly, so if you have:
1. 1/1/06 - 1/31/06 (22 Days)
2. 1/1/06 - 12/1/05 (- 22 Days - showing dates have been entered incorrectly.)
3. 1/1/06 - No End Date (-27655)
=IF(ISERROR(NETWORKDAYS(E23,F23)),"NA",NETWORKDAYS(E23,F23))
My concern is with #3, is there a way to instruct the formula that if columna and columb are not filled in,the result should be blank. Previously I had it where it indicated NA - but the problem with this is - while it appears fine in Excel, when I pull it into Access to report on I get the -27655. This is throwing my reporting off.
View 2 Replies
View Related
May 21, 2008
I am trying to do a macro that looks to see if the date is different from one cell to another going down in rows. I got it to work until the cell is empty then it says the date dont match but I just want it to stop the loop. so it should go down a list check to see if the date is the same all the way down the list, stopping if cell is blank, if not give a message box, if it is the same stop.
Is As follows
Dim rowNum As Integer, colNum As Integer, currCell As Range
rowNum = ActiveCell.Row
colNum = ActiveCell.Column
rowNum = rowNum + 1
'get first cell
Set currCell = ActiveSheet.Cells(2, 3)
'loop while cell not empty
Do Until currCell.Value = " "
If currCell.Value = ActiveSheet.Cells(2, 3) Then
If currCell.Value = "" Then
End If
View 4 Replies
View Related