Thema Datum  Von Nutzer Rating
Antwort
07.05.2025 13:18:25 Ralph
*
Solved
07.05.2025 13:37:29 Ralph
NotSolved
07.05.2025 15:00:41 Gast56740
NotSolved
07.05.2025 18:16:53 Ralph
NotSolved
07.05.2025 18:24:26 cysu11
NotSolved
07.05.2025 22:16:15 Ralph
NotSolved
Rot Shape Form je nach Wert in Zelle
08.05.2025 09:38:22 Ralph
NotSolved
12.06.2025 15:08:20 d'r Bastler
NotSolved

Ansicht des Beitrags:
Von:
Ralph
Datum:
08.05.2025 09:38:22
Views:
79
Rating: Antwort:
  Ja
Thema:
Shape Form je nach Wert in Zelle

Ich habe es jetzt mal wie von Gast56740 vorgeschlagen mit Select Case probiert und es funktioniert soweit auch sehr gut.

Meine Frage bzw. Bitte wäre aber trotzdem ob sich jemand den Code mal anschauen und mir sagen kann was ich da noch verbessern oder verfeinern kann. Ich würde daraus ja auch gerne lernen.........

Besten Dank aber schon mal bis hierhin für die Hilfe.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Sub UpdateShapesArPl()
 
Dim startRow As Long, LastRow As Long
Dim namesCol As String, colorCol As String
Dim i As Long, j As Long
Dim shpAltName As String, cellColor As Long
Dim shp As Shape
Dim newShapes As String, deletedShapes As String
Dim isShapeInData As Boolean
 
startRow = 2
namesCol = "B"
colorCol = "B"
 
LastRow = Sheet008.Cells(Sheet008.Rows.Count, namesCol).End(xlUp).Row
 
For i = startRow To LastRow
 
shpAltName = Sheet008.Cells(i, namesCol).Value
cellColor = Sheet008.Cells(i, colorCol).DisplayFormat.Interior.Color
 
Set shp = Nothing
For Each potentialShape In Sheet009.Shapes
 
If potentialShape.AlternativeText = shpAltName Then
 
Set shp = potentialShape
Exit For
 
End If
 
Next potentialShape
 
If shp Is Nothing Then
Select Case Sheet008.Cells(i, namesCol).Offset(0, -1).Value
 
Case "ArPl_kurz"
Set shp = Sheet009.Shapes.AddShape(msoShapeRectangle, 650, 30, 40, 25)
shp.AlternativeText = shpAltName
shp.Fill.ForeColor.RGB = cellColor
shp.TextFrame.Characters.Text = shpAltName
shp.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Size = 5
shp.TextFrame.Characters.Font.Bold = False
shp.Name = shpAltName
 
Case "Halle_kurz"
Set shp = Sheet009.Shapes.AddShape(msoShapeDownArrowCallout, 700, 30, 40, 30)
shp.AlternativeText = shpAltName
shp.Fill.ForeColor.RGB = cellColor
shp.TextFrame.Characters.Text = shpAltName
shp.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Size = 11
shp.TextFrame.Characters.Font.Bold = True
shp.Name = shpAltName
 
Case "IT_kurz"
Set shp = Sheet009.Shapes.AddShape(msoShapeFlowchartDecision, 750, 30, 25, 25)
shp.AlternativeText = shpAltName
shp.Fill.ForeColor.RGB = cellColor
shp.TextFrame.Characters.Text = shpAltName
shp.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Size = 5
shp.TextFrame.Characters.Font.Bold = False
shp.Name = shpAltName
 
Case "LOTO_kurz"
Set shp = Sheet009.Shapes.AddShape(msoShapeDonut, 800, 30, 10, 10)
shp.AlternativeText = shpAltName
shp.Fill.ForeColor.RGB = cellColor
shp.TextFrame.Characters.Text = shpAltName
shp.TextFrame.Characters.Font.Color = RGB(0, 0, 0)
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Size = 5
shp.TextFrame.Characters.Font.Bold = False
shp.Name = shpAltName
 
End Select
 
If newShapes = "" Then
 
newShapes = shpAltName
Else
newShapes = newShapes & vbNewLine & shpAltName
End If
 
End If
 
Next i
 
For Each shp In Sheet009.Shapes
shpAltName = shp.AlternativeText
isShapeInData = False
 
For j = startRow To LastRow
If Sheet008.Cells(j, namesCol).Value = shpAltName Then
isShapeInData = True
Exit For
End If
 
Next j
 
If Not isShapeInData And shpAltName <> "" Then
If deletedShapes = "" Then
deletedShapes = shpAltName
Else
deletedShapes = deletedShapes & vbNewLine & shpAltName
End If
shp.Delete
End If
 
Next shp
 
Dim message As String
 
If newShapes <> "" Then
message = "Folgende Shapes werden erstellt:" & vbNewLine & newShapes
MsgBox message, vbInformation, "Update neue Shapes"
End If
 
If deletedShapes <> "" Then
message = message & "Folgende Shapes werden gelöscht" & vbNewLine & deletedShapes
MsgBox message, vbInformation, "Update gelöschte Shapes"
End If
 
If message = "" Then
message = "Ausgewähltes Element" & vbNewLine & _
"wird im Layout angezeigt"
MsgBox message, vbInformation, "Update Auswahl"
End If
 
End Sub

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
07.05.2025 13:18:25 Ralph
*
Solved
07.05.2025 13:37:29 Ralph
NotSolved
07.05.2025 15:00:41 Gast56740
NotSolved
07.05.2025 18:16:53 Ralph
NotSolved
07.05.2025 18:24:26 cysu11
NotSolved
07.05.2025 22:16:15 Ralph
NotSolved
Rot Shape Form je nach Wert in Zelle
08.05.2025 09:38:22 Ralph
NotSolved
12.06.2025 15:08:20 d'r Bastler
NotSolved