VBA find closest sunday

Status
Not open for further replies.

cheerz4325

New Member
Joined
Nov 5, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello!

I need to find the next closest Sunday to November 30th each year using VBA functions.

Can someone help me? I am a beginner.

Thank you in advance!
 

Attachments

  • Kuvatõmmis 2021-11-07 125304.png
    Kuvatõmmis 2021-11-07 125304.png
    3.3 KB · Views: 30

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try this:

=WORKDAY.INTL(DATE(A1,12,1),-1,"1111110")

or:

=DATE(A1,12,1)-WEEKDAY(DATE(A1,12,1),2)

PHP:
Public Function LastSunday(ByVal Y As Long) As Date
Dim d As Date
d = DateSerial(Y, 12, 1)
LastSunday = d - Weekday(d, vbMonday)
End Function
 
Upvote 0
Duplicate to: VBA dates

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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