![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 133
|
I want a cell to display "Good Morning" if it is between 00:00 and 12:00, display "Good Afternoon" if it between 12:00 and 17:00 and finally display "Good Evening" if it is between 17:00 and 00:00. - any ideas.
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
When do you want to display this ? On opening ? on a cell (Formula ??) ? where ? when ? how ? (VBA / Formula) ?
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Posts: 133
|
I want to perform this task in a cell formula if possible e.g. =if(a1>17 etc.
|
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
="Good "&VLOOKUP(MOD(NOW(),1),{0,"Morning";0.5,"Afternoon";0.708333333333333,"Evening"},2)
[ This Message was edited by: Mark W. on 2002-03-28 12:42 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Posts: 133
|
Many thanks that's exactly what I needed.
Regards Nigel. |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Nigel, just in case it matters, the text will only update if there has been a cell calculation. Other wise it'll remain static.
|
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
Mark, slick use of the VLOOKUP array form.
Didn't know how it worked at first so I studied it. I never would have thought of the problem in that way, but I like it. As far as I can tell your formula works like this: VLOOKUP with array data returns the second element (Text) hence the 2 at the end of the formula. The general value of the MOD(NOW(),1) returns the NOW() remainder and VLOOKUP will use the largest value that is less than or equal to lookup_value. So it returns the proper text for the current time bracket from the array. Once again nice work. JSW |
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
|
Quote:
|
|
|
|
|
|
|
#9 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Quote:
My point was, if you leave the sheet ALONE, it will not change the text automatically (That's also why i said, in case it matters...) |
|
|
|
|
|
|
#10 |
|
Banned
Join Date: Feb 2002
Posts: 1,582
|
Couldn't you just use:
="Good " & IF(A1<0.5,"Morning",IF(A1<0.75,"Afternoon","Evening")) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|