Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
872to876
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
872to876
872to876
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Color.Index in Excel 2007

Color.Index in Excel 2007
27.05.2007 17:40:09
Michael
Hallo Excel Freunde,
Ich habe eine umfangreiche Mappe in Excel 2003 entwickelt. Dabei benutze ich VBA um Diagramme mit verschiedenen Texten und Texthintergründen darzustellen. Das hat in Excel 2003 bestens geklappt. Der Code sieht so aus:

Sub All_SetTrigramInside()
Dim i As Integer                     'Zähler
Dim intRow As Integer           'Zeilennummer auf dem Tabellenblatt
Dim chtTrigram As Chart         'Diagramm
Set chtTrigram = Sheet4.ChartObjects("trigrams").Chart
intRow = 134
For i = 1 To 24
With chtTrigram.SeriesCollection(2).Points(i)
.DataLabel.Characters.Text = Sheet27.Range("DF" & intRow)  Text
.Interior.ColorIndex = Sheet27.Range("DG" & intRow)   'Hintergrundfarbe
End With
intRow = intRow + 1
Next i
End Sub


In Excel 2007 beendet die Zeile "Interior.ColorIndex = Sheet27.Range("DG" & intRow)" das Programm vollständig und man muß neu starten. Durch Experimente habe ich herausgefunden, dass folgender Code, der viel umständlicher ist, funktioniert:


Sub All_SetTrigramInside()
Dim i As Integer                'Zähler
Dim intRow As Integer           'Zeilennummer auf dem Tabellenblatt
Dim chtTrigram As Chart         'Diagramm
Dim intColFont(24) As Integer          'Schriftfarbe
intRow = 134
For i = 1 To 24
intColFont(i) = Sheet27.Range("DG" & intRow)   'Einlesen Hintergrundfarbe Patch für 2007
intRow = intRow + 1
Next i
Set chtTrigram = Sheet4.ChartObjects("trigrams").Chart
intRow = 134
For i = 1 To 24
With chtTrigram.SeriesCollection(2).Points(i)
.DataLabel.Characters.Text = Sheet27.Range("DF" & intRow)  Text
.Interior.ColorIndex = intColFont(i)  'Hintergrundfarbe
End With
intRow = intRow + 1
Next i
End Sub


Woran liegt das? Excel 2007 kann nun viel mehr Farben darstellen. Wie kann ich herausfinden welche Farbnummer für welche Farbe steht? Und wie geht Excel 2003 dann mit dieser Nummer um?
Danke für Eure Hilfe
Michael

9
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Color.Index in Excel 2007
27.05.2007 17:45:00
Hajo_Zi
Hallo Michael,
in Excel 2007 sind es über 4 mio. Farben, da wird nicht mehr mit Colorindex gearbeitet sondern nur Color.

AW: Color.Index in Excel 2007
27.05.2007 17:56:00
Michael
Hallo Hajo,
danke für die schnelle Antwort am Sonntag!
Wenn ich das richtig verstehe muss man nun die RGB Werte für jede Farbe eingeben.
Wie kann man das aus einer Tabelle auslesen?
Und wie reagiert Excel 2002 und 2003 auf .color?
Schönen Gruß
Michael
PS: Kennst du eine VAB Hilfe (Buch, Download) speziell für Excel 2007?

AW: Color.Index in Excel 2007
27.05.2007 18:02:00
Hajo_Zi
Hallo Michael,
Versionen vor 2002 regieren darauf auch es wird nur eine der 56 Farben verwendet. Ich habe schon 2 Bücher zu 2007 aber noch keins zu VBA.
Du kannst RGB Werte eingeben oder "Farbindexwert.
Hier mal die 56 Farben vor 2007
Tabelle1

 ABCDEH
1 10000
2 225525525516777215
3 325500255
4 40255065280
5 50025516711680
6 6255255065535
7 7255025516711935
8 8025525516776960
9 912800128
10 100128032768
11 11001288388608
12 12128128032896
13 1312801288388736
14 1401281288421376
15 1519219219212632256
16 161281281288421504
17 1715315325516751001
18 18153511026697881
19 1925525520413434879
20 2020425525516777164
21 2110201026684774
22 222551281288421631
23 23010220413395456
24 2420420425516764108
25 25001288388608
26 26255025516711935
27 27255255065535
28 28025525516776960
29 2912801288388736
30 3012800128
31 3101281288421376
32 320025516711680
33 33020425516763904
34 3420425525516777164
35 3520425520413434828
36 3625525515310092543
37 3715320425516764057
38 3825515320413408767
39 3920415325516751052
40 4025520415310079487
41 415110225516737843
42 425120420413421619
43 43153204052377
44 44255204052479
45 45255153039423
46 46255102026367
47 4710210215310053222
48 481501501509868950
49 490511026697728
50 50511531026723891
51 51051013056
52 525151013107
53 5315351013209
54 54153511026697881
55 55515115310040115
56 565151513355443
57 IndexRotGrünBlauFarbindex
58  RGB Farbwerte  Summe

Bedingte Formatierungen der Tabelle
ZelleNr.: / BedingungFormat
H11. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H21. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H31. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H41. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H51. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H61. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H71. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H81. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H91. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H101. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H111. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H121. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H131. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H141. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H151. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H161. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H171. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H181. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H191. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H201. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H211. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H221. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H231. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H241. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H251. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H261. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H271. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H281. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H291. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H301. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H311. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H321. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H331. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H341. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H351. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H361. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H371. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H381. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H391. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H401. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H411. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H421. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H431. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H441. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H451. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H461. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H471. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H481. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H491. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H501. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H511. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H521. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H531. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H541. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H551. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc
H561. / Formel ist =ZÄHLENWENN(F:F;F1)>1Abc

Gruß Hajo

Anzeige
AW: Color.Index in Excel 2007
27.05.2007 18:15:00
Michael
Hallo Hajo,
Herzlichen Dank, Das hilft mir super weiter!
Gruß
Michael

AW: Color.Index in Excel 2007
28.05.2007 00:24:20
Michael
Hallo Hajo,
Jetzt bin ich dazu gekommen, deine Tabelle genauer anzusehen.
Leider verstehe ich die Formel =ZÄHLENWENN(F:F;F1)>1 nicht.
Die Spalten F und G sind nicht gezeigt.
Gibt es eine Funktion die RGB Farbwerte und den Farbindex zu berechnen?
Danke
Michael

AW: Color.Index in Excel 2007
28.05.2007 07:50:00
Hajo_Zi
Hallo Michael,
der Auszug ist nur ein Teil meiner Farbliste, das die bedingte Formatierung ausgelesen wurde war ein Fehler. Die bedingte Formatierung ist dazu da um zu zeigen welche Farben bei Colorindex (56 Farben) doppelt sind.
Die Tabelle wurde kommplett über VBA erstellt. Es gibt als auch einen VBA Code um eine Farbe in RGB Werte aufzuteilen. Den Code habe ich unter Version 2000 estellt und noch nicht auf 2007 umgestellt.
Für die Umwandlung könnte man folgenden Code als Grundlage nehmen.

Sub RGBAnzeige()
'   auf Grundlage von einem Code von Nepumuk
Dim Rot As Long, Grün As Long, Blau As Long, Wert As Long
' ****** Ergänzung Hajo
Dim i As Integer
For i = 1 To 56
'       Farbe in Spalte A
Cells(i, 1).Interior.ColorIndex = i
Wert = Cells(i, 1).Interior.Color
On Error Resume Next
Rot = Wert Mod 256
Wert = (Wert - Rot) / 256
Grün = Wert Mod 256
Wert = (Wert - Grün) / 256
Blau = Wert Mod 256
'        MsgBox Rot & ", " & Grün & ", " & Blau
' ***** Ergänzung Hajo
Cells(i, 3) = Rot
Cells(i, 4) = Grün
Cells(i, 5) = Blau
Next i
'***** Ergänzung Hajo
Cells(57, 3) = "Rot"
Cells(57, 4) = "Grün"
Cells(57, 5) = "Blau"
Cells(58, 3) = "RGB Farbwerte"
End Sub


Aber man kommt ja auch mit dem "Farbindex" klar.
Gruß Hajo

Anzeige
AW: Color.Index in Excel 2007
28.05.2007 11:44:00
Michael
Hallo Hajo,
danke für deine Tabelle. Sie funktioniert in Excel 2007 genau wie bechrieben!
Ich bin noch verwirrt über die Begriffe colorindex and Farbindex...
Ich versteh, dass Excel 2007 .colorindex nicht mehr akzeptiert, da es nun Millionen von Farben gibt.
Wenn man nun stattdessen .color verwendet, kann man RGB Werte verwenden, die man aus deiner Tabelle gewinnen kann. Wie komme ich aber zu diesem neuen Farbwert oder Farbindex, der alle Millionen Farben abdeckt. Excel zeigt ihn nicht an, nur die RGB Werte. Gibt es hier auch eine Berechnungsmethode oder ien andere Tabelle? Bei deiner Tabelle steht da "Summe".
Gruß
Michael

Anzeige
AW: Color.Index in Excel 2007
28.05.2007 15:37:08
Hajo_Zi
Hallo Michael,
ich habe es mal als Farbindex bezeichnet, den genauen begriff habe ich noch nicht gefunden und auch nicht nach gesucht. Fäbe eine Zelle

Sub Michael()
MsgBox ActiveCell.Interior.Color
End Sub


Gruß Hajo

AW: Color.Index in Excel 2007
29.05.2007 08:50:00
Michael
Hallo Hajo,
Danke, jetzt ist es klar!
Gruß Michael

119 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige