Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro needed

I need a macro that will auto enter the week ending date into a cell. anyone
help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro needed

Try this:

Sub lastDOW()
dif = "6" - Format(Date, "w")
lstDOW = Format(Now + dif, "d mmm yyyy")
ActiveSheet.Range("A1") = CDate(lstDOW)
End Sub

It posts the date in A1 in the sytem format as data type Date. You can
either format the cell to change it or modify the code.




"david24" wrote:

I need a macro that will auto enter the week ending date into a cell. anyone
help?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro needed

Thanks, the "6" needs to be an "8" though!

"JLGWhiz" wrote:

Try this:

Sub lastDOW()
dif = "6" - Format(Date, "w")
lstDOW = Format(Now + dif, "d mmm yyyy")
ActiveSheet.Range("A1") = CDate(lstDOW)
End Sub

It posts the date in A1 in the sytem format as data type Date. You can
either format the cell to change it or modify the code.




"david24" wrote:

I need a macro that will auto enter the week ending date into a cell. anyone
help?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro needed

There are only seven days in a week. How can you use 8 and get an answer
that gives a result for Friday which is day number 6.

Friday - Thrusday = 1, Thursday + 1 = Friday
Eight - Thursday = 3, Thursday + 3 = Sunday
Eight - Friday = 4, Friday + 4 = 10 which will give the
wrong date for the end of week day.

The code should subtract the current day of the week from the end of the
week day. This gives the number of days left until the end of the week.
Then add that number to the current date to get the date for the end of week
day.

Maybe I did not understand the question.




"david24" wrote:

Thanks, the "6" needs to be an "8" though!

"JLGWhiz" wrote:

Try this:

Sub lastDOW()
dif = "6" - Format(Date, "w")
lstDOW = Format(Now + dif, "d mmm yyyy")
ActiveSheet.Range("A1") = CDate(lstDOW)
End Sub

It posts the date in A1 in the sytem format as data type Date. You can
either format the cell to change it or modify the code.




"david24" wrote:

I need a macro that will auto enter the week ending date into a cell. anyone
help?

Reply
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
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro/VB Help Needed olrustyxlsuser Excel Programming 5 May 9th 07 05:11 AM
Macro needed to set macro security in Excel to minimum Carl Excel Programming 3 March 18th 06 03:36 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


All times are GMT +1. The time now is 11:27 PM.

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

About Us

"It's about Microsoft Excel"