How to Get Holiday in VBA Code

punnipah

Board Regular
Joined
Nov 3, 2021
Messages
134
Office Version
  1. 2019
Platform
  1. Windows
Hi,,



I want to write the date on excel 3 days in advance but not counting weekend and holidays.

How to type VBA Code

Range("D4").Value = Format(DateAdd("d", 3, Date), "D MMM YY")



Thank you .
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi,

Check below:

VBA Code:
Range("D4").Value = Format(WorksheetFunction.WorkDay(Date, 3, Sheets("Sheet2").Range("A1:A3")), "D MMM YY")

Range A1 to A3 contains Holiday dates.

Book1
ABC
104-Feb-22
207-Feb-22
315-Feb-22
4
5
6
7
Sheet2
 
Upvote 0
Thank y
Hi,

Check below:

VBA Code:
Range("D4").Value = Format(WorksheetFunction.WorkDay(Date, 3, Sheets("Sheet2").Range("A1:A3")), "D MMM YY")

Range A1 to A3 contains Holiday dates.

Book1
ABC
104-Feb-22
207-Feb-22
315-Feb-22
4
5
6
7
Sheet2
Thank you very much.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,823
Members
449,470
Latest member
Subhash Chand

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