Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Jeff
 
Posts: n/a
Default Auto_Open() How to show prior Monday?

This code gets me the 1st day of the current workweek. I need to edit it to
get the 1st day of the previous workweek.

Sub Auto_Open()
' Enter the prior Monday
Set StartDay = Sheets("SamB").Range("StartDay")
StartDay.Value = Date
Do Until Weekday(StartDay) = 2
StartDay.Value = StartDay.Value - 1
Loop
End Sub

I would appreciate your help.
Thanks,

Jeff

  #2   Report Post  
Harald Staff
 
Posts: n/a
Default

Hi Jeff

Sub MakePevMonday()
Dim D As Date
D = Date - Weekday(Date, vbMonday) - 6
Sheets("SamB").Range("StartDay").Value = D
End Sub

HTH. Best wishes Harald

"Jeff" skrev i melding
...
This code gets me the 1st day of the current workweek. I need to edit it

to
get the 1st day of the previous workweek.

Sub Auto_Open()
' Enter the prior Monday
Set StartDay = Sheets("SamB").Range("StartDay")
StartDay.Value = Date
Do Until Weekday(StartDay) = 2
StartDay.Value = StartDay.Value - 1
Loop
End Sub

I would appreciate your help.
Thanks,

Jeff



  #3   Report Post  
Jeff
 
Posts: n/a
Default

Hi Harald,
Thank You, this worked.
May I ask?, What is "Dim" and "vbMonday" or how do they work?
I am pretty new to excel but finding myself addicted to it. I am reading up
as much as I can but some of this stuff is pretty easy and some of it goes
way over my head.
Thanks again, I realy appreciate your help.

Jeff

"Harald Staff" wrote:

Hi Jeff

Sub MakePevMonday()
Dim D As Date
D = Date - Weekday(Date, vbMonday) - 6
Sheets("SamB").Range("StartDay").Value = D
End Sub

HTH. Best wishes Harald

"Jeff" skrev i melding
...
This code gets me the 1st day of the current workweek. I need to edit it

to
get the 1st day of the previous workweek.

Sub Auto_Open()
' Enter the prior Monday
Set StartDay = Sheets("SamB").Range("StartDay")
StartDay.Value = Date
Do Until Weekday(StartDay) = 2
StartDay.Value = StartDay.Value - 1
Loop
End Sub

I would appreciate your help.
Thanks,

Jeff




  #4   Report Post  
Harald Staff
 
Posts: n/a
Default

Hi Jeff

Dim is important, it declares the variables to be used. See any book on
programming or do a Google search on the topic "declare variables", it's
really essential programming and too big a topic to be reasonably described
here. This one seem like a good start
http://www.beyondtechnology.com/vba008.shtml

vbMonday, on the other hand, is a part of the Weekday function in Vb,
defining which weekday is number 1. Not important at all in the big picture.

HTH. Best wishes Harald

"Jeff" skrev i melding
...
Hi Harald,
Thank You, this worked.
May I ask?, What is "Dim" and "vbMonday" or how do they work?
I am pretty new to excel but finding myself addicted to it. I am reading

up
as much as I can but some of this stuff is pretty easy and some of it goes
way over my head.
Thanks again, I realy appreciate your help.

Jeff

"Harald Staff" wrote:

Hi Jeff

Sub MakePevMonday()
Dim D As Date
D = Date - Weekday(Date, vbMonday) - 6
Sheets("SamB").Range("StartDay").Value = D
End Sub

HTH. Best wishes Harald

"Jeff" skrev i melding
...
This code gets me the 1st day of the current workweek. I need to edit

it
to
get the 1st day of the previous workweek.

Sub Auto_Open()
' Enter the prior Monday
Set StartDay = Sheets("SamB").Range("StartDay")
StartDay.Value = Date
Do Until Weekday(StartDay) = 2
StartDay.Value = StartDay.Value - 1
Loop
End Sub

I would appreciate your help.
Thanks,

Jeff






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
show macro security setting in a cell Mark Excel Worksheet Functions 3 March 21st 05 07:53 AM
pivot table - hide details but show subtotal for calculated field tenneym Excel Discussion (Misc queries) 1 February 9th 05 03:07 AM
UDF and Calculation tree Ken Wright Links and Linking in Excel 1 February 6th 05 04:58 PM
hide column but show chart Svetlana Charts and Charting in Excel 1 January 14th 05 09:49 AM
Show a date based on today DJ Dusty Excel Worksheet Functions 2 November 12th 04 03:20 AM


All times are GMT +1. The time now is 02:19 PM.

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

About Us

"It's about Microsoft Excel"