Conditional & dynamically filling cell or range with Excel VBA

Cakz Primz

Board Regular
Joined
Dec 4, 2016
Messages
104
Office Version
  1. 365
Platform
  1. Windows
Dear all,

I have two columns of "annual leave" date, as below:
column AB = Start Date
column AC = End Date

While in column AJ, cell AJ1 until cell PO1 I have list of sequence date, starting from Dec 1, 2024 until Dec 31, 2025.

Let's say in cell:
AB2 = Dec 22, 2024
AC2 = Dec 27, 2025
Duration = 5 days

How to write "L" in row # 2, starting from column with the date equal to AB2 (Start Date) until column with the date equal to AC2 (End Date), using Excel VBA or Excel formula?

Thank you very much in advance.

Best regards,
prima - Indonesia
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Something like this perhaps? (I've hidden a lot of columns to demonstrate)

Book1
ABACADBCBDBEBFBGBHBIBJBKPGPHPIPJPKPLPMPNPO
1Start DateEnd DateDec 20, 2024Dec 21, 2024Dec 22, 2024Dec 23, 2024Dec 24, 2024Dec 25, 2024Dec 26, 2024Dec 27, 2024Dec 28, 2024Dec 23, 2025Dec 24, 2025Dec 25, 2025Dec 26, 2025Dec 27, 2025Dec 28, 2025Dec 29, 2025Dec 30, 2025Dec 31, 2025
2Dec 22, 2024Dec 27, 2025  LLLLLLLLLLLL    
3
Sheet1
Cell Formulas
RangeFormula
BC2:BK2,PG2:PO2BC2=IF(AND(BC1>=$AB$2,BC1<=$AC$2),"L","")
 
Upvote 0
Solution
Try. In AJ2. column AA and AB are taken from row 2 to 4. Adjust as required.
Excel Formula:
=LET(dts,AJ1:PO1,MAKEARRAY(ROWS(AA2:AA4),COLUMNS(dts),LAMBDA(r,c,IF((INDEX(AA2:AA4,r)<=INDEX(dts,c))*(INDEX(AB2:AB4,r)>=INDEX(dts,c)),"L",""))))
 
Upvote 0
Dear kevin9999,

Thank you so much, the formula given is working very well.
May God bless you.

Problem solved.

Best regards,
prima - Indonesia
 
Upvote 0

Forum statistics

Threads
1,226,101
Messages
6,188,921
Members
453,511
Latest member
Refugar

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