View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Martin[_2_] Bill Martin[_2_] is offline
external usenet poster
 
Posts: 105
Default Sharing a workbook breaks VBA code?

What do you mean "it did not work for them"?

Did it lock up their machine?
Generate error messages?
Just quietly do nothing?
Work properly, but put up the wrong colors?
Something else?

More info would be helpful.

Bill
-----------------------------

Jason wrote:
The following code acts as conditional formatting (as conditional formatting
only allows for 3 conditions) for a worksheet shared by multiple people. When
I added the code and tested it, everything seemed to work fine. That was
until another individual let me know that it did not work for them. Upon
further investigation, it seems that I am the only one that he code works
for. Does sharing the workbook in essence break/ignore the code? Is there a
workaround for this type of problem. Many thanks in advance.

Private Sub Worksheet_Change(ByVal Target As Range)
Set t = Intersect(Target, Range("A3:A50"))
If Not t Is Nothing Then
Upper t
FillCells t
End If
End Sub

Public Sub Upper(ByVal Target As Range)
Application.EnableEvents = False
Target.Value = UCase(Target.Value)
Application.EnableEvents = True
End Sub

Public Sub FillCells(ByVal Target As Range)
Select Case Target
Case "X"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 15
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
Case "P"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 6
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
Case "L"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 45
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
Case "D"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 50
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
Case "QA"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 38
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
Case "QC"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 55
.Font.ColorIndex = 2
End With
Next c
Case "S"
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = 53
.Font.ColorIndex = 2
End With
Next c
Case Else
For c = 1 To 12
With Target(1, c)
.Interior.ColorIndex = xlColorIndexNone
.Font.ColorIndex = xlColorIndexAutomatic
End With
Next c
End Select
End Sub