Thema Datum  Von Nutzer Rating
Antwort
Rot VBA Loops
15.12.2016 17:47:11 Robinkio
NotSolved
15.12.2016 17:50:20 Mackie
NotSolved
15.12.2016 17:53:45 Robinkio
NotSolved
15.12.2016 17:54:27 Robinkio
NotSolved
15.12.2016 17:54:41 Robinkio
NotSolved
15.12.2016 18:31:18 Onur
NotSolved
15.12.2016 18:53:29 Onur
NotSolved
15.12.2016 21:42:21 Onur
NotSolved

Ansicht des Beitrags:
Von:
Robinkio
Datum:
15.12.2016 17:47:11
Views:
1376
Rating: Antwort:
  Ja
Thema:
VBA Loops
Hallo zusammen Ich habe das Problem, dass aufgrund ungenügender VBA-Kenntnisse meine Codes zu lang werden und ich es nicht hinkriege, diese mit intelligentem coden zu kürzen. :-) Nachfolgend poste ich ein Beispiel eines Codes, nach welchem die Farbe unterschiedlicher Excel-Formen bestimmt werden soll. Das Schwierigkeit ist, dass es je nach Wert für die unterschiedlichen Formen eine unterschiedliche Einfärbung geben soll (5 Farbstufen/Preisstufen). Hat jemand von euch eine Idee, wie ich den folgenden Code kürzen könnte? Danke schon einmal. 'Form 1a If Worksheets("Pivot_Planogramm").Range("BE6").Formula >= .Range("D31") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E31") And Worksheets("Code").Range("C4") = 1 Then .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F31").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D32") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E32") And Worksheets("Code").Range("C4") = 1 Then .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F32").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D33") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E33") And Worksheets("Code").Range("C4") = 1 Then .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F33").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D34") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E34") And Worksheets("Code").Range("C4") = 1 Then .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F34").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BE6") >= .Range("D35") And Worksheets("Pivot_Planogramm").Range("BE6") <= .Range("E35") And Worksheets("Code").Range("C4") = 1 Then .Shapes("Form 1a").Fill.ForeColor.RGB = Range("F35").Interior.Color Else .Shapes("Form 1a").Fill.ForeColor.RGB = vbWhite End If 'Form 1b If Worksheets("Pivot_Planogramm").Range("BF6").Formula >= .Range("D31") And Worksheets("Pivot_Planogramm").Range("BF6") <= .Range("E31") Then .Shapes("Form 1b").Fill.ForeColor.RGB = Range("F31").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BF6") >= .Range("D32") And Worksheets("Pivot_Planogramm").Range("BF6") <= .Range("E32") Then .Shapes("Form 1b").Fill.ForeColor.RGB = Range("F32").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BF6") >= .Range("D33") And Worksheets("Pivot_Planogramm").Range("BF6") <= .Range("E33") Then .Shapes("Form 1b").Fill.ForeColor.RGB = Range("F33").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BF6") >= .Range("D34") And Worksheets("Pivot_Planogramm").Range("BF6") <= .Range("E34") Then .Shapes("Form 1b").Fill.ForeColor.RGB = Range("F34").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BF6") >= .Range("D35") And Worksheets("Pivot_Planogramm").Range("BF6") <= .Range("E35") Then .Shapes("Form 1b").Fill.ForeColor.RGB = Range("F35").Interior.Color Else .Shapes("Form 1b").Fill.ForeColor.RGB = vbWhite End If 'Form 1c If Worksheets("Pivot_Planogramm").Range("BG6").Formula >= .Range("D31") And Worksheets("Pivot_Planogramm").Range("BG6") <= .Range("E31") Then .Shapes("Form 1c").Fill.ForeColor.RGB = Range("F31").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BG6") >= .Range("D32") And Worksheets("Pivot_Planogramm").Range("BG6") <= .Range("E32") Then .Shapes("Form 1c").Fill.ForeColor.RGB = Range("F32").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BG6") >= .Range("D33") And Worksheets("Pivot_Planogramm").Range("BG6") <= .Range("E33") Then .Shapes("Form 1c").Fill.ForeColor.RGB = Range("F33").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BG6") >= .Range("D34") And Worksheets("Pivot_Planogramm").Range("BG6") <= .Range("E34") Then .Shapes("Form 1c").Fill.ForeColor.RGB = Range("F34").Interior.Color ElseIf Worksheets("Pivot_Planogramm").Range("BG6") >= .Range("D35") And Worksheets("Pivot_Planogramm").Range("BG6") <= .Range("E35") Then .Shapes("Form 1c").Fill.ForeColor.RGB = Range("F35").Interior.Color Else .Shapes("Form 1c").Fill.ForeColor.RGB = vbWhite End If End With

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
Rot VBA Loops
15.12.2016 17:47:11 Robinkio
NotSolved
15.12.2016 17:50:20 Mackie
NotSolved
15.12.2016 17:53:45 Robinkio
NotSolved
15.12.2016 17:54:27 Robinkio
NotSolved
15.12.2016 17:54:41 Robinkio
NotSolved
15.12.2016 18:31:18 Onur
NotSolved
15.12.2016 18:53:29 Onur
NotSolved
15.12.2016 21:42:21 Onur
NotSolved