Habe gestern im Forum von "Mustafa" den unteren Code bekommen.(Nochmals DANKE)
Der besagt: Wenn in B8:AO19 ein "X" steht das mir eine Linie von "X" bis zum nächsten "X" gezeichnet wird.Wenn ich auf "M2" einen Doppelklick mache wird die Tabelle aktualisiert.
Nun möchte ich aber wenn ich auf "J2" einen Doppelklick mache,das die Linien von B8:AO19 wieder gelöscht werden.
Könnte mir dabei Bitte jemand helfen.
Danke & Gruss, Heinz
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address(0, 0) = "M2" Then
Cancel = True
Dim l!, t!, l1!, t1!
Application.ScreenUpdating = False
ActiveSheet.Unprotect
For x = 2 To 40
For y = 8 To 19
For z = 8 To 19
If Cells(y, x) = "x" And Cells(z, x + 1) = "x" Then
With Cells(y, x)
l = .Left + (.Width / 2)
t = .Top + (.Height / 2)
End With
With Cells(z, x + 1)
l1 = .Left + (.Width / 2)
t1 = .Top + (.Height / 2)
End With
With ActiveSheet.Shapes.AddLine(l, t, l1, t1).Line
.Weight = 2#
.ForeColor.RGB = RGB(255, 55, 55)
End With
End If
Next z
Next y
Next x
ActiveSheet.Protect
Application.ScreenUpdating = True
End If
End Sub