Thema Datum  Von Nutzer Rating
Antwort
07.05.2025 13:18:25 Ralph
NotSolved
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

Ansicht des Beitrags:
Von:
Ralph
Datum:
08.05.2025 09:38:22
Views:
39
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.

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
NotSolved
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