LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 166
Default Need a hand with date calc

On Wed, 4 Mar 2009 20:59:48 -0800 (PST), CurlyDave
wrote:

My appologies, 12/30/39 is a Saturday, I must have entered 1940
originally, also my bad, for the formula provided is a worksheet
formula, not a VBA code.
Here it is again with the proper weekday

=DATE(YEAR(E1),MONTH(E1),DAY(E1)+CHOOSE(WEEKDAY(E 1),-1,-2,-3,3,2,1,0))


If you wanted a VBA code to Change E1 to the nearest Saturday, then
perhaps a helper cell would work.

Sub NearestSat()
Dim h As Range
Set h = Range("H1")
h.Value = "=DATE(YEAR(E1),MONTH(E1),DAY(E1)+CHOOSE(WEEKD AY
(E1),-1,-2,-3,3,2,1,0))"
Range("E1") = Range("H1").Value
h.ClearContents
End Sub


Thanks Dave, I should have picked that code was a cell formula but
it's an area I've not dabbled in yet.
That's a neat trick with a helper cell, and I've sucessfully applied
that and substituted it for my longer routine. It became somewhat
clearer when I realised E1 was a cell, not a variable!

Cheers - Kirk
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calc. an anniversary date(50 years) after marriage date in excel datakop Excel Worksheet Functions 3 January 4th 10 11:03 PM
ND TO CALC FROM ORIG DATE TO NEXT DATE RECEIVED? HELP FRANCES Excel Discussion (Misc queries) 1 June 28th 07 07:15 AM
y-axis moves from the left hand side to the right hand side JP Excel Discussion (Misc queries) 1 March 13th 05 04:43 PM
y-axis moves from the left hand side to the right hand side! JP Charts and Charting in Excel 1 March 11th 05 12:29 AM
calc constant date from variable date & return with ability to rn. SusieQ'sQuest Excel Worksheet Functions 1 November 9th 04 08:51 PM


All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"