Deactivate macros but reactivate again once another macro is run

B

Ber

I am very new to Macros. I have a workbook first sheet sign in sign out of
work and I have a macro attached to each day sign in and sign out (button)
but once the button is pushed once I want to deactive it(macro) for that week
but I use another macro to copy the weeks entries to sheet 2 on Fridays and
clear cells to get ready for the next weeks entries; now when I use the macro
to do this I also want to reactivate the ones I have deactivated. In other
words once someone has signed in on Monday I do not want them to be able to
use that button again till the following Monday after that weeks entries have
been moved and sheet reset but then want my macros to work again.Macro code
below for first sheet and undermeath code for 2nd sheet. Thanks in advance.
Sub currenttime1()
' Time Macro
' Macro recorded 19/04/2010 by cooganb
Sheets("Weekly Time Sheet").Unprotect Password:="working925"
t = Time()
Set Displaytime = Sheets(1).Range("e12")
Displaytime.Cells(1, 1) = Str(t)
Sheets("Weekly Time Sheet").Protect Password:="working925"
End Sub

Sub PostandClear()
'
' PostandClear Macro
' Macro recorded 16/04/2010 by cooganb
'
' Keyboard Shortcut: Ctrl+p
'
Sheets("AMALGAMATED").Select
Sheets("AMALGAMATED").Unprotect Password:="working925"
Range("A6").Select
Selection.EntireRow.Insert , CopyOrigin:=xlFormatFromRightOrBelow
Sheets("Weekly Time Sheet").Select
Sheets("Weekly Time Sheet").Unprotect Password:="working925"
Range("D24:AL24").Select
Selection.Copy
Sheets("AMALGAMATED").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("AMALGAMATED").Protect Password:="working925"
Sheets("Weekly Time Sheet").Select
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("E12").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("E13").Select
Selection.ClearContents
Range("E15").Select
Selection.ClearContents
Range("E16").Select
Selection.ClearContents
Range("E18").Select
Selection.ClearContents
Range("E19").Select
Selection.ClearContents
Range("E20").Select
Selection.ClearContents
Range("G12").Select
Selection.ClearContents
Range("G13").Select
Selection.ClearContents
Range("G15").Select
Selection.ClearContents
Range("G16").Select
Selection.ClearContents
Range("G18").Select
Selection.ClearContents
Range("G19").Select
Selection.ClearContents
Range("G20").Select
Selection.ClearContents
Range("I12").Select
Selection.ClearContents
Range("I13").Select
Selection.ClearContents
Range("I15").Select
Selection.ClearContents
Range("I16").Select
Selection.ClearContents
Range("I18").Select
Selection.ClearContents
Range("I19").Select
Selection.ClearContents
Range("I20").Select
Selection.ClearContents
Range("K12").Select
Selection.ClearContents
Range("K13").Select
Selection.ClearContents
Range("K15").Select
Selection.ClearContents
Range("K16").Select
Selection.ClearContents
Range("K18").Select
Selection.ClearContents
Range("K19").Select
Selection.ClearContents
Range("K20").Select
Selection.ClearContents
Range("M12").Select
Selection.ClearContents
Range("M13").Select
Selection.ClearContents
Range("M15").Select
Selection.ClearContents
Range("M16").Select
Selection.ClearContents
Range("M18").Select
Selection.ClearContents
Range("M19").Select
Selection.ClearContents
Range("M20").Select
Selection.ClearContents
Range("O12").Select
Selection.ClearContents
Range("O13").Select
Selection.ClearContents
Range("O15").Select
Selection.ClearContents
Range("O16").Select
Selection.ClearContents
Range("O18").Select
Selection.ClearContents
Range("O19").Select
Selection.ClearContents
Range("O20").Select
Selection.ClearContents
Range("Q12").Select
Selection.ClearContents
Range("Q13").Select
Selection.ClearContents
Range("Q15").Select
Selection.ClearContents
Range("Q16").Select
Selection.ClearContents
Range("Q18").Select
Selection.ClearContents
Range("Q19").Select
Selection.ClearContents
Range("Q20").Select
Selection.ClearContents
Range("G12").Select
Sheets("Weekly Time Sheet").Protect Password:="working925"
End Sub
 
J

JLatham

Just check for the day of the week at the beginning of the routines:

If Weekday(Now(),1) <> 2 Then
'not Monday, quit
Exit Sub
End If
....rest of your login code

and

If Weekday(Now(),1)<>6 Then
'Not Friday, quit
Exit Sub
End If
.... the rest of your posting code

By the way - you can delete all of those ActiveWindow.ScrollColumn = #
lines of code in the posting code to clean it up some.
 
B

Ber

Thank you so much this code certainly worked today Monday and will test for
the rest of the week, you are a genius thanks a mill will report after Friday.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Run Time Error 7
Auto run macro 1
Clearing an Active X text box with a macro 3
Saving file with ref. to one cell 0
Macro code 0
Selection.ClearContents makes macro halt??? 4
macro trouble 2
protect with password 6

Top