VBA function assign value to date based on distance

gero92

New Member
Joined
Apr 15, 2018
Messages
10
Hi everybody,

I have a list of dates (Events) and another list of dates that fall in between those (special events). I want to do a vba function that finds the special event in the calendar, and add to each calendar date 10 divided by the number in between the 2 event dates that contain the special event date, only if a special date is in between the 2 event dates. The function has to count the number of days between the event dates and leave the 5 days before and after the special date blank and assign the value to the other dates. I attach an example of the excel down here, the value to be assigned date is what the vba should return. The excel is dynamic so dates and number of days in between change everyday.

I have been breaking my head on this for so long, I'd be sooooo grateful if anybody could help! thank you !

Special EventEventCalendarDistance Value to be assigned
28/04/1820/04/1820/04/18
18/05/1805/05/1821/04/1872.52.5=10 (count of days between the event dates)
20/06/1804/06/1822/04/1862.5
02/11/1806/07/1823/04/185
24/02/1909/09/1824/04/184Nothing here as it is 5 days before/after the special date
29/05/1913/11/1825/04/183
17/01/1926/04/182
23/03/1927/04/181
27/05/1928/04/180
31/07/1929/04/181
04/10/1930/04/182
01/05/183
02/05/184
03/05/185
04/05/1862.5
05/05/1872.5
06/05/1880.59
07/05/1890.59
08/05/18100.590.59 = (10/17, 17 is the number of days between the 2 event dates)
09/05/1890.59
10/05/1880.59
11/05/1870.59
12/05/1860.59
13/05/185
14/05/184
15/05/183
16/05/182
17/05/181
18/05/180
19/05/181
20/05/182
21/05/183
22/05/184
23/05/185
24/05/1860.59
25/05/1870.59
26/05/1880.59
27/05/1890.59
28/05/18100.59
29/05/18110.59
30/05/18120.59
31/05/18130.59
01/06/18140.59
02/06/18150.59
03/06/18160.59
04/06/1816
05/06/1815
06/06/1814
07/06/1813
08/06/1812
09/06/1811
10/06/1810
11/06/189
12/06/188
13/06/187
14/06/186
15/06/185
16/06/184
17/06/183
18/06/182
19/06/181
20/06/180
21/06/181
22/06/182
23/06/183
24/06/184
25/06/185
26/06/186
27/06/187
28/06/188
29/06/189
30/06/1810
01/07/1811
02/07/1812
03/07/1813
04/07/1814
05/07/1815
06/07/1816
07/07/1817
08/07/1818
09/07/1819
10/07/1820
11/07/1821
12/07/1822
13/07/1823
14/07/1824
15/07/1825
16/07/1826
17/07/1827
18/07/1828
19/07/1829
20/07/1830
21/07/1831
22/07/1832
23/07/1833
24/07/1834
25/07/1835
26/07/1836
27/07/1837
28/07/1838
29/07/1839
30/07/1840
31/07/1841
01/08/1842
02/08/1843
03/08/1844
04/08/1845
05/08/1846
06/08/1847
07/08/1848
08/08/1849
09/08/1850
10/08/1851
11/08/1852
12/08/1853
13/08/1854
14/08/1855
15/08/1856
16/08/1857
17/08/1858
18/08/1859
19/08/1860
20/08/1861
21/08/1862
22/08/1863
23/08/1864
24/08/1865
25/08/1866
26/08/1867
27/08/1867

<colgroup><col><col span="4"><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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