Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 318
Default Weekday function Not right

Hello I have a workbook and one worksheet for each weekday in a month .
Using the example for May 2008. On Cell J1 I have the date 5/1/08. On the
second sheet on J1 I have the following formula
='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,1) and it gives me 5/2/08 .
sheet 3 J1='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,2) gives me 5/3/05 .
sheet 4 ='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,4) and it gives me May
5, 2008.
What I've been doing is manually changing the last number of the formula
to give me the day I want. What is the correct formula so that I do not
have to manually change each formula in every sheet (every month) thanks in
advance
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Weekday function Not right

Use a macro:

Sub ChangeDates()
Dim i As Integer
Dim myDate As Date
myDate = DateSerial(Year(Date), Month(Date) + IIf(MsgBox("For this Month?", vbYesNo) = vbYes, 0, 1),
1)
If Weekday(myDate, vbSaturday) <= vbMonday Then myDate = myDate + 3 - Weekday(myDate, vbSaturday)
For i = 1 To Worksheets.Count
Worksheets(i).Range("J1").Value = myDate
myDate = myDate + IIf(Weekday(myDate + 1, vbSunday) = vbSaturday, 3, 1)
Next i
End Sub

Answer Yes if you want the dates for the current month, or No if you want the dates for next month.

HTH,
Bernie
MS Excel MVP


"Wanna Learn" wrote in message
...
Hello I have a workbook and one worksheet for each weekday in a month .
Using the example for May 2008. On Cell J1 I have the date 5/1/08. On the
second sheet on J1 I have the following formula
='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,1) and it gives me 5/2/08 .
sheet 3 J1='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,2) gives me 5/3/05 .
sheet 4 ='05-01-08'!J1+IF(WEEKDAY('05-01-08'!J1+1)=7,2,4) and it gives me May
5, 2008.
What I've been doing is manually changing the last number of the formula
to give me the day I want. What is the correct formula so that I do not
have to manually change each formula in every sheet (every month) thanks in
advance



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
Weekday function? Cam Excel Discussion (Misc queries) 1 February 26th 08 08:58 PM
WEEKDAY() function: display TEXT not numeric weekday tom Excel Discussion (Misc queries) 3 November 21st 06 04:32 PM
WEEKDAY Function? JP Excel Worksheet Functions 5 April 21st 06 06:54 PM
Weekday Function John Excel Worksheet Functions 2 January 7th 05 11:39 AM
weekday function John New Users to Excel 0 January 7th 05 11:13 AM


All times are GMT +1. The time now is 12:13 AM.

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"