Data matching using datetime fields between 2 tables

arevilo

New Member
Joined
Jan 29, 2021
Messages
1
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi All,

I have 2 tables of data: i. Orders Data and ii. Events Data.

In the Orders Data table the fields are: Customer_ID , Order_ID , Start_Datetime, End_Datetime

In the Events Data table the fields are: Customer_ID, Event_ID, Event_Datetime

There are many other fields but the above are the relevant ones. The Orders Data table is very messy and for that and other reasons I want to add the new columns into the Events Data table.

Essentially, I want to create 3 fields.
For each Customer_ID I want to:
1. concatenate all the Order_ID into one cell that meet the rule:Start_Datetime <= Event_Datetime <= End_Datetime

2. Count the number of orders that meet the rule above.

3. Identify the Order_ID where the (Start_Datetime <= Event_Datetime) AND has the smallest time difference. Ie. Is the closest order before the event occurred.


I would like the vba code please. Could we use arrays?
Is there faster ways in excel?

Any help is greatly appreciated! :)
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Data matching using datetime fields between 2 tables
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,425
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top