PC Review


Reply
Thread Tools Rate Thread

Deactivate macros but reactivate again once another macro is run

 
 
Ber
Guest
Posts: n/a
 
      23rd Apr 2010
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

 
Reply With Quote
 
 
 
 
JLatham
Guest
Posts: n/a
 
      23rd Apr 2010
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.

"Ber" wrote:

> 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
>

 
Reply With Quote
 
Ber
Guest
Posts: n/a
 
      26th Apr 2010
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.

"JLatham" wrote:

> 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.
>
> "Ber" wrote:
>
> > 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
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deactivate a macro when used and reactivate again Ber Microsoft Excel Misc 1 23rd Apr 2010 04:35 PM
Deactivate then Reactivate UpdateLinks =?Utf-8?B?VE9NQg==?= Microsoft Excel Programming 2 24th Feb 2006 10:20 PM
Cannot deactivate, and reactivate Windows XP SP1 =?Utf-8?B?RGltaXRyaXMgQ2hvbnR6b3BvdWxvcw==?= Windows XP General 3 9th Dec 2005 08:56 AM
Deactivate and reactivate David Microsoft Windows 2000 Terminal Server Clients 2 8th Oct 2003 09:56 PM
deactivate - reactivate license server Dick Wright Microsoft Windows 2000 Terminal Server Clients 0 19th Aug 2003 11:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 PM.