LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Date/Day VBA Calculation

That's a Beautiful solution!!! Thanks Greatly!!



"Mike H" wrote:

Rob,

Try this

tDate = Date - WeekDay(Date, 2) + 1

For future work you simply change the last 1 to a 2 for Tuesday etc.

Mike

"Rob" wrote:

I was wondering how I can get VBA in Excel'03 to recognize that if today is
Tuesday the 17th, or Firday the 20th, then the previous Monday must have been
the 16th. Or is it is Friday April the 3rd then the previous Monday was
March 30th? Escentially I am just looking for a way to have the VB identify
what Day today is as well as the date and then calculate what the previous
Monday was... Unless the current day happens to actually be Monday, in which
case it just uses that date.

Dim tDate, mDate As Date

tDate = Format(Now(),"m/d/yyyy")
tDay = Day(tDate)

If tDay < "Monday" Then mDate = tDate - tDay

The above code it what I toyed with but it has failed at every itteration I
made of it.


Thanks In Advance!

 
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
A specific date used for calculation of a new date Ditte Excel Discussion (Misc queries) 7 July 17th 09 08:00 AM
Date Calculation (from entered date / 1yr later in next field) ajaminb Excel Worksheet Functions 6 September 29th 08 02:11 PM
End Date Calculation (adding a start date duration) Silena K-K Excel Discussion (Misc queries) 5 January 25th 08 04:27 PM
Tricky Date calculation: How to calculate a future date [email protected] Excel Discussion (Misc queries) 9 August 11th 06 04:24 AM
Coding to show first _weekday_ prior to a date, when date calculation happens to fall on weekend? StargateFan[_3_] Excel Programming 5 December 9th 04 09:06 AM


All times are GMT +1. The time now is 06:54 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"