VBA: goto cell in column A:A that contains date of sunday for curent week.

mike760534211

New Member
Joined
Sep 25, 2014
Messages
13
I have looked everywhere and unable to locate my answer. is is possible to write some VBA code that would, at the click of a button, go to the cell in Column A that contains the date for Sunday of the current week.

Column A contains dates that fall on every Sunday from start of 2014 - 12/9/2029.

example:
Current week is 11/23/2014-11/29/2014
Today is 11/25/2014
Current Weeks Sunday date is 11/23/2014

then when opening the book I could potentially be in cell A1 but click a button and it takes me to cell A52 which actually contains 11/23/2014 which is the current weeks Sunday date.

Apologies in advance if i am unclear or confusing.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi,

Try this:
Code:
Sub FindSunday()
    With Sheet2
        .Activate
        .Cells(CLng(Application.Match(CLng(Date - Weekday(Date) + 1), .Columns(1), 0)), 1).Activate
    End With
End Sub

It starts with Date, subtracts the number of days after Sunday then Matches that date with what is in column A.
Mine works for Sheet2 - you will probably need to change that.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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