Hi,
When I activate my Worksheet ‘Medarbejdere’, I get an error-message.
“Runtime error ‘1004’. Application – defined or object – defined error.”
It comes in the line
.Add Type:=…
I can’t see why it comes? And it is only sometimes the error comes! Can You?
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
Range(Cells(7, 29), Cells(46, 34)).Locked = False
‘ making the list/name ‘Ruter’
i = 2
Do Until Worksheets("Rutetider").Cells(i, 1).Value = ""
Worksheets("Rutetider").Cells(i + 2, 43).Value = Worksheets("Rutetider").Cells(i, 1).Value
i = i + 1
Loop
Names("Ruter").Delete
Names.Add Name:="Ruter", RefersTo:="=Rutetider!$AQ$2:$AQ$" & i + 1
Unprotect Password:="xxx"
Cells.Validation.Delete
‘ making the dropdownlist in the cells
For i = 7 To 46
If Cells(i, 27).Value <> "" And Cells(i, 27).Value <> "Ledig" Then
With Range(Cells(i, 29), Cells(i, 34)).Validation
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=Ruter"
.InCellDropdown = True
.ShowInput = False
.ShowError = False
End With
End If
Next i
Me.Protect Password:="xxx", userinterfaceonly:=True
Application.ScreenUpdating = True
End Sub
Thanks.
Woody93