Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
780to784
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
780to784
780to784
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Diagramm Aktualisieren

Diagramm Aktualisieren
14.07.2006 10:47:57
Heinz
Hallo Leute
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

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Diagramm Aktualisieren
14.07.2006 14:27:41
Dan
Hallo Heinz, so koennte es sein. Gruss Dan.
Option Explicit
Private m_colLines As Collection
Private m_shpLine As Shape
Private x, y, z

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.ScreenUpdating = False
ActiveSheet.Unprotect
If Target.Address(0, 0) = "M2" Then
Cancel = True
Dim l!, t!, l1!, t1!
Set m_colLines = New Collection
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
Set m_shpLine = ActiveSheet.Shapes.AddLine(l, t, l1, t1)
m_colLines.Add m_shpLine
With m_shpLine.Line
.Weight = 2#
.ForeColor.RGB = RGB(255, 55, 55)
End With
End If
Next z
Next y
Next x
End If
If (Target.Address(0, 0) = "J2") Then
Cancel = True
For Each m_shpLine In m_colLines
m_shpLine.Delete
Next m_shpLine
Set m_colLines = New Collection
End If
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub

Anzeige
AW: Diagramm Aktualisieren
15.07.2006 09:29:32
Herbert
hallo Heinz,
so geht's...


If Target.Address = "$J$2" Then
    Cancel = True
    Dim shp As Shape
    ActiveSheet.Unprotect
    For Each shp In ActiveSheet.Shapes
        If shp.Type = msoLine Then shp.Delete
    Next
End If

     gruß Herbert
https://www.herber.de/bbs/user/35095.xls
Anzeige
AW: Diagramm Aktualisieren
15.07.2006 09:34:01
Heinz
Hallo Herbert
Recht herzlichen Dank.
Jetzt funktioniert es.
Danke & Gruss, Heinz

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige