Umwandeln in ein Modul
02.01.2015 17:46:54
Ilch
Hallo zusammen
Ich habe mir unten stehenden Code hier aus dem Forum zusammen gebaut. Er hat auch immer sehr gut funktioniert, doch leider ist mein rechner so schwach auf der Brust auf arbeit, das er sich immer aufhängt wenn ich änderungen im Tabellenblatt vornehme. Deshalb wäre es toll wenn mir jemand aus diesem Code ein standartmodul machen könnte so das der code nur einmal ausgeführt wird wenn ich einen Button klicke.
Hier mal der Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pos As Integer
pos = InStr(Target.Cells(1, 1), "S1")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=2).Font
.FontStyle = "Fett"
.ColorIndex = 1
End With
End If
pos = InStr(Target.Cells(1, 1), "S2")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=2).Font
.FontStyle = "Fett"
.ColorIndex = 29
End With
End If
pos = InStr(Target.Cells(1, 1), "S3")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=2).Font
.FontStyle = "Fett"
.ColorIndex = 3
End With
End If
pos = InStr(Target.Cells(1, 1), "S4")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=2).Font
.FontStyle = "Fett"
.ColorIndex = 41
End With
End If
pos = InStr(Target.Cells(1, 1), "S5")
If pos > 0 Then
With Target.Characters(Start:=pos, Length:=2).Font
.FontStyle = "Fett"
.ColorIndex = 5
End With
End If
End Sub
Ich hoffe mir kann jemand helfen.
Viele Grüße und ein frohes neues Jahr
Ilch