Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1048to1052
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
Inhaltsverzeichnis

Code Vereinfachung

Code Vereinfachung
10.02.2009 11:47:00
Björn
Ich prüfe im Vorweg bestimmte Variablen ab, (Metallic, radio etc....)
Für jede Verneinung steht x mit einem Wert. Für jede Bejahung steht x mit 0.
Das ganze lese ich in eine Datei ein aus der wiederum dann eine Listbox zur Anzeige befüllt wird
RW Abschlag FaktorAufschlag
Keine Metallic / Perleffekt oder Schwarzlackierung -3 0,5
.........
Da jedes x entweder Wahr oder Falsch sein kann, würden diverse Leerzeilen bei der Auslesung entstehen daher die Variable z. Ich kann die Dateil leider nicht hochladen, da zuviele sensible Daten da drinnen sind. Vielleicht kann mir ja doch jemand einen Ansatz geben wie ich den Nachstehenden Code in eine Schleife bekomme. Da es insgesamt um mehr als 20 Prüfungen geht hat man zum schluss 20 mal die z Variable.
If x 0 Then 'Metallic/Perleffekt/Schwarz
z = 1
Cells(204 + z, 11).FormulaR1C1 = "Keine Metallic / Perleffekt oder Schwarzlackierung"
Cells(204 + z, 12).FormulaR1C1 = x
Cells(204 + z, 13).FormulaR1C1 = y
Else
z = 0
End If
If x1 0 Then 'Radio
z1 = 1
Cells(204 + z + z1, 11).FormulaR1C1 = "Kein Radio"
Cells(204 + z + z1, 12).FormulaR1C1 = x1
Cells(204 + z + z1, 13).FormulaR1C1 = y1
Else
z1 = 0
End If
If x2 0 Then 'Telefon
z2 = 1
Cells(204 + z + z1 + z2, 11).FormulaR1C1 = "Kein Telefon oder Handy"
Cells(204 + z + z1 + z2, 12).FormulaR1C1 = x2
Cells(204 + z + z1 + z2, 13).FormulaR1C1 = y2
Else
z2 = 0
End If
If x3 0 Then 'weiß
z3 = 1
Cells(204 + z1 + z2 + z3 + z4, 11).FormulaR1C1 = "Weiße Lackierung"
Cells(204 + z1 + z2 + z3 + z4, 12).FormulaR1C1 = x3
Cells(204 + z1 + z2 + z3 + z4, 13).FormulaR1C1 = y3
Else
z3 = 0
End If
If x4 0 Then 'rot
z4 = 1
Cells(204 + z + z1 + z2 + z3 + z4, 11).FormulaR1C1 = "Rote Lackierung"
Cells(204 + z + z1 + z2 + z3 + z4, 12).FormulaR1C1 = x4
Cells(204 + z + z1 + z2 + z3 + z4, 13).FormulaR1C1 = y4
Else
z4 = 0
End If
If x5 0 Then 'Automatik
z5 = 1
Cells(204 + z + z1 + z2 + z3 + z4 + z5, 11).FormulaR1C1 = "Kein Automatik Getriebe"
Cells(204 + z + z1 + z2 + z3 + z4 + z5, 12).FormulaR1C1 = x5
Cells(204 + z + z1 + z2 + z3 + z4 + z5, 13).FormulaR1C1 = y5
Else
z5 = 0
End If
If x6 0 Then '3-türig
z6 = 1
Cells(204 + z + z1 + z2 + z3 + z4 + z5 + z6, 11).FormulaR1C1 = "Fahrzeug ist 3-türig"
Cells(204 + z + z1 + z2 + z3 + z4 + z5 + z6, 12).FormulaR1C1 = x6
Cells(204 + z + z1 + z2 + z3 + z4 + z5 + z6, 13).FormulaR1C1 = y6
Else
.........

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Erklärung vereinfachen,
10.02.2009 12:26:00
RS
Hi Björn,
Wie soll frau deinen Code vereinfachen, wenn sie schon die ersten beiden Sätze nicht versteht?
Ich prüfe im Vorweg bestimmte Variablen ab, (Metallic, radio etc....)
Für jede Verneinung steht x mit einem Wert. Für jede Bejahung steht x mit 0.

Was heisst x mit einem Wert?
Was heisst x mit 0
Aus Deiner Art zu programmieren kann ich mir absolut keinen Reim machen. Schon gar nicht, weil mir eine allgemein verständliche Problembeschreibung fehlt!
Grüsse RS
AW: Code Vereinfachung
10.02.2009 13:41:40
Björn
So ich hab mal versucht meine Code aus der entsprechenden Datei herauszuziehen.
Kann sicherlich sein das dass dadurch der eine oder andere Bug sich eingeschlichen hat.
Wie gesagt mir geht es um die Befüllen der Listbox, hier würde ich gerne eine Schleife bilden.
Bin für Ideen sehr dankbar :).
https://www.herber.de/bbs/user/59305.xls
Grüße Björn
Anzeige
Sorry, ich klink mich aus...
10.02.2009 13:54:27
RS
ich versteh nur Bahnhof, obwohl ich nicht bei der Deutschen Bahn arbeite.
Das Problem ist für mich nicht nachvollziehbar, darum bleibt die Frage offen.
Grüsse RS
Frage offen....
10.02.2009 13:56:00
RS

AW: Frage offen....
10.02.2009 15:27:45
Jens
Hallo Björn
Ich blicke auch nicht durch Dein Problem durch.
Aber mal nen Hinweis zur Variablen-Deklarierung:

Dim z, z1, z2, z3, z4, z5, z6, z7, z8, z9, z10, z11, z12, z13, z14, z15 As Integer


So wie Du die Variablen deklarierst, wird nur z15 als Integer deklariert, alle anderen werden automatisch als Variant deklariert.
Gruß Jens

Anzeige
AW: Code Vereinfachung
11.02.2009 19:58:00
Caruso
Hallo Björn,
einfach z als Zähler (z1-z? entfallen dann)

z=0
If x  0 Then 'Metallic/Perleffekt/Schwarz
z = z+1
Cells(204 + z, 11) = "Keine Metallic / Perleffekt oder Schwarzlackierung"
Cells(204 + z, 12) = x
Cells(204 + z, 13) = y
End If
If x1  0 Then 'Radio
z = z+1
Cells(204 + z, 11) = "Kein Radio"
Cells(204 + z, 12) = x1
Cells(204 + z, 13) = y1
End If
If x2  0 Then 'Telefon
z = z+1
Cells(204 + z, 11) = "Kein Telefon oder Handy"
Cells(204 + z, 12) = x2
Cells(204 + z, 13) = y2
End If
If x3  0 Then 'weiß
z = z+1
Cells(204 + z, 11) = "Weiße Lackierung"
Cells(204 + z, 12) = x3
Cells(204 + z, 13) = y3
End If
uswusw...


Gruß
Carlo

Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige