Wat is je eigenlijke code?
Dit is de (gedeeltelijke) code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim i As Integer
Dim cell As Range
'Dim MyVar As Variant
'Dim myCell As Range
'Dim Column As Range
Dim myRange As Range
Dim msg As String
Dim Password
Application.ScreenUpdating = False
Password = "tralala"
ActiveSheet.Unprotect Password
If (starting_up = False) Then
'-(1)------------------------------------------------------------------------------------
For Each cell In Target
If ((ActiveCell.row > 34) And (ActiveCell.row < 602)) Then
If ((ActiveCell.Column > 5) And (ActiveCell.Column < 255)) Then
'Alle cellen met ingevulde waarden voorzien van hun correcte opmaakkleur.
If cell.Value = "" Or 0 Then
'voor de rijenafwisseling in wit - lichtblauw tbv de "voorw." opmaak
Target.Interior.ColorIndex = 20
cell.FormatConditions.Delete
cell.Interior.Pattern = xlSolid
cell.FormatConditions.Add Type:=xlExpression, Formula1:="=REST(RIJ();2)=0"
cell.FormatConditions(1).Interior.ColorIndex = 34
Else
'en de "gewone" opmaak
If cell.Value > 0 Then Target.FormatConditions.Delete
If cell.Value > 0 Then cell.Font.Name = "Tahoma"
If cell.Value > 0 Then cell.Font.ColorIndex = 0
If cell.Value > 0 Then cell.Font.Bold = False
'en de rest
If cell.Value = Range("A10") Then cell.Interior.ColorIndex = 35
If cell.Value = Range("A11") Then cell.Interior.ColorIndex = 24
If cell.Value = Range("A12") Then cell.Interior.ColorIndex = 40
If cell.Value = Range("A13") Then cell.Interior.ColorIndex = 36
If cell.Value = Range("A14") Then cell.Interior.ColorIndex = 42
If cell.Value = Range("A15") Then cell.Interior.ColorIndex = 45
End If 'Else If cell.Value = "" Or 0
End If '((ActiveCell.column > 5) And (ActiveCell.column < 255))
End If '((ActiveCell.row > 34) And (ActiveCell.row < 602))
Next cell
'-(2)-----------------------------------------------------------------------------------
For Each cell In Target
If ((ActiveCell.row > 34) And (ActiveCell.row < 602)) Then
If (ActiveCell.Column = 1) Then
Dim mySheet As Object
Set mySheet = Sheets("projecten")
Dim MyColumn As Range
Set MyColumn = Range("A:A")
Dim MyVar As Variant
MyVar = Range("A" & ActiveCell.row).Value
Selection.Activate 'zonder deze regel werkt de macro niet
'Set myCell = Range("A" & ActiveCell.row)
'Sheets("projecten").Select
mySheet.Select
Password = "tralala"
ActiveSheet.Unprotect Password
'Column("A:A").Select
MyColumn.Select
Range("A10").Select
Bij MyColumn blijft ie hangen!
enz.
enz.
enz.
Password = "tralala"
ActiveSheet.Protect Password, True, True, True
Application.ScreenUpdating = True
End Sub