meine Excelmappe enthält einige Makros. Leider stürzt sie immer ab. Den Fehler habe ich in der Sub Worksheet_Activate() ausgemacht. Hier mal der Code:
Private Sub Worksheet_Activate()
Dim col As New Collection
Dim iRow As Integer
Dim sVal As String
'generieren der Gültigkeitsliste
iRow = 2
On Error Resume Next
With Worksheets("Tabelle2")
Do Until IsEmpty(.Cells(iRow, 1))
col.Add .Cells(iRow, 1).Value, .Cells(iRow, 1).Value
iRow = iRow + 1
Loop
End With
On Error GoTo 0
For iRow = 1 To col.Count
If iRow = 1 Then
sVal = col(iRow)
Else
sVal = sVal & "," & col(iRow)
End If
Next iRow
'Worksheets("Tabelle1").Unprotect
With Range("C8").Validation
.Delete
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=sVal
.IgnoreBlank = True
.InCellDropdown = True
End With
Worksheets("Tabelle1").Protect
End Sub
Insbesondere der Teil...:
Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=sVal
macht Probleme. Hat jemand eine Idee wie ich diesen Fehler beheben kann oder die ganze Sub so umschreiben kann, das es funzt? Vielen Dank für eure Tipps.
Grüße
Tobias