Code im Modul bei changein activesheet ausführe
18.07.2018 08:38:19
legac
ich habe mehr als 50 Tabellenblätter auf welche (nicht gleichzeitig) ein code ausgeführt werden soll sobald eine active ist und drin einen wert geändert wird.
ich will aber nicht in jeder Tabellenblatt den code einzeln kopieren sondern ihn einmalig zb. in einem Modul haben von wo es dann ausgeführt wird.
leider weiss ich nicht was ich falsch mache.
ich bekomme ein Fehler beim ausführen : Methode oder Datenobjekt nicht gefunden und zwar auf die Zeile (c=.Target.row)
hier mein code im Modul:
Public Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
Dim i, j, c, r, t As Integer
Dim wks As Worksheet
Set wks = ActiveWorkbook.ActiveSheet
If Intersect(Target, Range("C6:I16")) Is Nothing Then Exit Sub
With wks
c = .Target.Row
r = .Target.Address
t = .Target.Column
If .Cells(c, t).Value "" Then
If t = 3 Then
.Application.Range(Cells(c, t + 1), Cells(c, 9)).Select
ElseIf t = 9 Then
.Application.Range(Cells(c, 3), Cells(c, t - 1)).Select
Else
.Application.Union(.Range(Cells(c, 3), Cells(c, t - 1)), .Range(Cells(c, t + 1), Cells(c, _
_
_
9))).Select
End If
.Application.EnableEvents = False
.Selection.Interior.ColorIndex = 0
.Selection.ClearContents
.Application.EnableEvents = True
End If
For j = 3 To t
.Cells(c, j).Interior.ColorIndex = j * 2
Next j
.Cells(1, 1).Select
End With
End Sub
vielen Dank für eure Hilfe
Grüße
Legacys