ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What a silly question ! (https://www.excelbanter.com/excel-programming/371092-what-silly-question.html)

tom

What a silly question !
 
Hi everyone,

I am facing the following situation:

A1= Monday;
A2=if(weekday(A1,2)<6,"Week","Weekend")

in A2, we should have: "Week", if the content of A1= Monday,
Tuesday,...Friday.
Or "Weekend", if the content of A1: Saturday or Sunday.

It doesn't work ! Why ?

Please help me !
Thanks very much
Tom

NickHK

What a silly question !
 
Tom,
If you read the help on WEEKDAY, you will see it "Returns the day of the
week corresponding to a date".
So you have to pass a date (Now(), "01/12/06" etc).

NickHK

"tom" wrote in message
...
Hi everyone,

I am facing the following situation:

A1= Monday;
A2=if(weekday(A1,2)<6,"Week","Weekend")

in A2, we should have: "Week", if the content of A1= Monday,
Tuesday,...Friday.
Or "Weekend", if the content of A1: Saturday or Sunday.

It doesn't work ! Why ?

Please help me !
Thanks very much
Tom




tony h[_162_]

What a silly question !
 

I would guess that you have A1 as a string "Monday" rather than a date
which is a monday. try putting 31-aug-2006 in A1

regards


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=574101


Niek Otten

What a silly question !
 
Hi Tom,

Your method assumes you have a real Excel date in A1.
If you have text like "Monday":

=IF(OR(A1="Sunday",A1="Saturday"),"weekend","week" )

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"tom" wrote in message ...
| Hi everyone,
|
| I am facing the following situation:
|
| A1= Monday;
| A2=if(weekday(A1,2)<6,"Week","Weekend")
|
| in A2, we should have: "Week", if the content of A1= Monday,
| Tuesday,...Friday.
| Or "Weekend", if the content of A1: Saturday or Sunday.
|
| It doesn't work ! Why ?
|
| Please help me !
| Thanks very much
| Tom



Simon Cleal

What a silly question !
 
It doesn't work becuase "Monday" is text not a date serial number

If you put 22/08/2006 in A1 then it will work

Alternativly you could use =IF(LEFT(A1,1)="S","Weekend","Week")

HTH
Simon


"tom" wrote:

Hi everyone,

I am facing the following situation:

A1= Monday;
A2=if(weekday(A1,2)<6,"Week","Weekend")

in A2, we should have: "Week", if the content of A1= Monday,
Tuesday,...Friday.
Or "Weekend", if the content of A1: Saturday or Sunday.

It doesn't work ! Why ?

Please help me !
Thanks very much
Tom


tom

What a silly question !
 
Hi Nick and Simon,

Thanks very much for the indication.
However in A1, we must introduce the day in text as: "Monday",
"Tuesday",..."Friday".

and then in A2, we should test whether we are during the week, or it is the
weekend.

Thanks a lot
Tom


"Simon Cleal" wrote:

It doesn't work becuase "Monday" is text not a date serial number

If you put 22/08/2006 in A1 then it will work

Alternativly you could use =IF(LEFT(A1,1)="S","Weekend","Week")

HTH
Simon


"tom" wrote:

Hi everyone,

I am facing the following situation:

A1= Monday;
A2=if(weekday(A1,2)<6,"Week","Weekend")

in A2, we should have: "Week", if the content of A1= Monday,
Tuesday,...Friday.
Or "Weekend", if the content of A1: Saturday or Sunday.

It doesn't work ! Why ?

Please help me !
Thanks very much
Tom


tom

What a silly question !
 
Hi Niek,

Yes it works !!!

thanks very much for the indication and your kind help.
Thanks very much also to all those who tried to help me.
regards
Tom



"Niek Otten" wrote:

Hi Tom,

Your method assumes you have a real Excel date in A1.
If you have text like "Monday":

=IF(OR(A1="Sunday",A1="Saturday"),"weekend","week" )

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"tom" wrote in message ...
| Hi everyone,
|
| I am facing the following situation:
|
| A1= Monday;
| A2=if(weekday(A1,2)<6,"Week","Weekend")
|
| in A2, we should have: "Week", if the content of A1= Monday,
| Tuesday,...Friday.
| Or "Weekend", if the content of A1: Saturday or Sunday.
|
| It doesn't work ! Why ?
|
| Please help me !
| Thanks very much
| Tom




NickHK

What a silly question !
 
Tom,
Use Niek's option then.

NickHK

"Tom" wrote in message
...
Hi Nick and Simon,

Thanks very much for the indication.
However in A1, we must introduce the day in text as: "Monday",
"Tuesday",..."Friday".

and then in A2, we should test whether we are during the week, or it is

the
weekend.

Thanks a lot
Tom


"Simon Cleal" wrote:

It doesn't work becuase "Monday" is text not a date serial number

If you put 22/08/2006 in A1 then it will work

Alternativly you could use =IF(LEFT(A1,1)="S","Weekend","Week")

HTH
Simon


"tom" wrote:

Hi everyone,

I am facing the following situation:

A1= Monday;
A2=if(weekday(A1,2)<6,"Week","Weekend")

in A2, we should have: "Week", if the content of A1= Monday,
Tuesday,...Friday.
Or "Weekend", if the content of A1: Saturday or Sunday.

It doesn't work ! Why ?

Please help me !
Thanks very much
Tom





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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com