date

S

Stan Halls

I have 7 files and each file rep a day, what i am after is a button that when
pressed will insert the date into a cell
if we go with a monday file, if i open this file and press a button i need
the script to somehow give me the correct date for the current monday if
pressed on a monday or the next monday no matter which day after monday the
button is pressed,
any ideas
 
D

Don Guillett

try

Sub nextmonday()
If Weekday(Date) = 2 Then
mydate = Date
Else
mydate = Date + (9 - Weekday(Date))
End If
ActiveCell = mydate
End Su
 
S

Stan Halls

My understanding of scripts is limited, will that work is i run it tomorow ,
will it still find the date of the next monday
 
E

edwardpestian

Could I expand on this idea and have it place today's date in a specific
cell instead of the active cell. Once today's date has been placed in
the cell, it would not change until the button is pressed again.

Thanks.

ep
 
C

CLR

Try this mod of Don's code.......

Sub nextmonday()
If WeekDay(Date) = 2 Then
mydate = Date
Else
mydate = Date + (9 - WeekDay(Date))
End If
Range(Range("b1").Value).Value = mydate
End Sub

Put a cell address in B1 and run the macro to put the date in that cell.

Vaya con Dios,
Chuck, CABGx3
 
Top