Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Return Value based on Day of Week

I have the following situation:

I'm trying to key off of the agent ID in Column A and based on todays
day of the week return the start time of the agent from column D. I
can index it to get me the start time, but don't know how to formulate
the date part of the equation. Any help would be greatly appreciated!

Agent ID Agent Name Day Start Stop
--------- -------------------- --- ------ ------
2012069 Abel, Richard Howard Sun 18:00 0:00
Mon 18:00 0:00
Tue 18:00 0:00
Wed 18:00 0:00
Thu 18:00 0:00
Fri -OFF-- -OFF--
Sat -OFF-- -OFF--
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Return Value based on Day of Week

weekday returns a number from 1 to 7 with Sunday equals 1. The row offset of
Sunday with respect to the agent row is 0, not 1 which is returned by weekday
function. therefore you must subtract 1 from weekday function to get the
offset of the row which contains the day of the week. See code below.

Sub gettimes()


daynumber = Weekday(Date)
agentnumber = 2012069

Set c = Columns("A:A").Find(what:=agentnumber, _
LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
starttime = c.Offset(daynumber - 1, 3)
endtimetime = c.Offset(daynumber - 1, 4)

End If

End Sub


" wrote:

I have the following situation:

I'm trying to key off of the agent ID in Column A and based on todays
day of the week return the start time of the agent from column D. I
can index it to get me the start time, but don't know how to formulate
the date part of the equation. Any help would be greatly appreciated!

Agent ID Agent Name Day Start Stop
--------- -------------------- --- ------ ------
2012069 Abel, Richard Howard Sun 18:00 0:00
Mon 18:00 0:00
Tue 18:00 0:00
Wed 18:00 0:00
Thu 18:00 0:00
Fri -OFF-- -OFF--
Sat -OFF-- -OFF--

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
Return dates based on month and day of week lesg46 Excel Worksheet Functions 8 January 4th 07 12:47 AM
How to return week number from date? Mike Excel Worksheet Functions 0 November 30th 06 11:28 AM
How to return week number from date? rmcsantos Excel Worksheet Functions 0 November 30th 06 11:07 AM
Return day of week for 1 January dalymjl Excel Worksheet Functions 4 January 23rd 06 09:25 PM
Return the day of week for 1 January dalymjl About this forum 0 January 20th 06 08:17 PM


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