LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default Code seems to stop, but no error messages show up

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
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
Stop and show error alvin Kuiper Excel Discussion (Misc queries) 2 May 14th 09 12:26 PM
How to stop error messages from showing phil-rge-ee Excel Programming 2 April 12th 06 06:05 PM
Setting to stop error messages from showing? JENNYC Excel Discussion (Misc queries) 5 February 24th 06 10:05 PM
Statusbar messages stop updating [email protected] Excel Programming 4 November 30th 05 01:01 AM
Giving out code in messages BizMark Excel Discussion (Misc queries) 1 August 12th 05 02:09 PM


All times are GMT +1. The time now is 10:14 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"