Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The main part of the following code works great when I run it
from an icon my machine. Now trying to add this code to an add-in to be distributed. When I try F8, it does go into Call Green, but just loops and loops, without turning any cells green. When I run the Print Contracts from my custom menu, based on the worksheet and workbook protection status, the code seems to skip the Call Green and End sub. Can anyone please check and advise what I am missing here? Option Explicit Sub PrintContract() ' PrintContract Macro ' Keyboard Shortcut: NONE Application.ScreenUpdating = False Worksheets("Contract").Select ActiveSheet.Unprotect Password:="1234" Cells.Select Selection.Interior.ColorIndex = -4142 ActiveSheet.Protect Password:="1234" Worksheets("Contract").PrintOut Copies:=1, Collate:=True Call Green Application.ScreenUpdating = True End Sub Sub Green() ActiveWorkbook.Unprotect Password:="4321" ActiveSheet.Unprotect Password:="1234" '=============================================== Dim CELL As Range, tempR As Range, rangeToCheck As Range Cells.Select Cells.Interior.ColorIndex = -4142 For Each CELL In Intersect(Selection, ActiveSheet.UsedRange) If Not CELL.Locked Then If tempR Is Nothing Then Set tempR = CELL Else Set tempR = Union(tempR, CELL) End If End If Next CELL If tempR Is Nothing Then MsgBox "There are no Unlocked cells " & _ "in the selected range." End End If 'Select qualifying cells 'TempR.Select tempR.Interior.ColorIndex = 4 'GREEN ' ================================================= ActiveSheet.Protect Password:="1234" ActiveWorkbook.Protect Password:="4321" End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Stop and show error | Excel Discussion (Misc queries) | |||
How to stop error messages from showing | Excel Programming | |||
Setting to stop error messages from showing? | Excel Discussion (Misc queries) | |||
Statusbar messages stop updating | Excel Programming | |||
Giving out code in messages | Excel Discussion (Misc queries) |