Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1028to1032
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
Optionbuttons müssen einen Wert wiedergeben
07.12.2008 20:59:00
Thierry
Hallo!
In einer Userform habe ich verschiedene Option Buttons. Je nachdem welche Options Buttons gewählt werden, muss das Resultat in Zelle 8 bzw 9, "1" oder "0" sein.
Teilcode
Cells(ActiveCell.Row, 8) = IIf(OptMobiCar.Value = True And optConclusione1.Value = True, 1, 0)
Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione2.Value = True, 1, 0)
Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione3.Value = True, 1, 0)
Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione5.Value = True, 1, 0)

Wenn ich es nur mit der 1. und 2. Zeile, oder 1. und 3. Zeile, oder 1. und 4. Zeile versuche, stimmt das Resultat. Wenn ich es aber mit den 4 Zeilen gleichzeitig versuche, ergibt die 2. und 3 Zeile nicht den gewünschten Wert.
Für jede Hilfe bin ich Euch dankbar.
Gruss.
Thierry

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Optionbuttons müssen einen Wert wiedergeben
07.12.2008 21:41:06
Uwe
Hi Thierry,
ich kann das jetzt schlecht testen, aber versuch einfach mal statt der letzten drei Zeilen nur das hier:

Cells(ActiveCell.Row, 9) = _
IIf(OptMobiCar.Value = True _
And (optConclusione2.Value = True _
Or optConclusione3.Value = True _
Or optConclusione5.Value = True), _
1, 0)


Vielleicht klappt es ja (Ich drücke die Daumen)
Gruß
Uwe
(:o)

AW: Optionbuttons müssen einen Wert wiedergeben
07.12.2008 23:07:00
Gerd
Hallo Thierry,
so ?
Dim i As Integer, arrConcl As Variant
arrConcl = Array(optConclusione2.Value, optConclusione3.Value, optConclusione5.Value)
For i = 2 To 0 Step -1
If arrOptConcl(i) = True Then Exit For
Next
i = Application.Min(1, i + 1)
Cells(ActiveCell.Row, 9) = OptMobiCar.Value * -i
Cells(ActiveCell.Row, 8) = OptMobiCar.Value * optConclusione1.Value

Gruß Gerd
Anzeige
AW: Optionbuttons müssen einen Wert wiedergeben
08.12.2008 13:11:00
Thierry
Hallo Uwe
Leider funktioniert deine Lösung nicht. Dennoch danke ich Dir.
Hallo Gerd
Mit VBA habe ich so meine Mühe. Ich habe versucht deine Lösung in meinem Code einzufügen um deinen Vorschlag zu testen, leider erscheint die Fehlermeldung:
Fehler beim Kompilieren
Sub oder Function nicht definiert
Sicherlich weisst du wo der Fehler liegt.
Gruss.
Thierry
Code

Private Sub cmdConfermareGenerali_Click()
On Error GoTo Fehler
Unload Me
'Rami assicurativo
Cells(ActiveCell.Row, 4) = IIf(OptLainf, "Lainf", "") + IIf(OptMac, "Malattia collettiva", " _
") + IIf(OptMobiCar, "MobiCar", "") + IIf(OptMobiCasa, "MobiCasa", "") + IIf(OptMobiLifeProposta, "MobiLife", "") + IIf(OptMobiPro, "MobiPro", "") + IIf(OptMobiSana, "MobiSana", "") + IIf(OptMobiTech, "MobiTech", "") + IIf(OptMobiTour, "MobiTour", "") + IIf(OptProtekta, "Protekta", "") + IIf(OptTS, "Tariffa semplice", "")
'Tipo di conclusione
Cells(ActiveCell.Row, 6) = IIf(optConclusione1, "Nuovo affare", "") + IIf(optConclusione2, " _
Modifica firmata", "") + IIf(optConclusione3, "Modifica non firmata", "") + IIf(optConclusione4, "Modifica e nuovo affare", "") + IIf(optConclusione5, "Rinnovo d'ufficio", "")
'Luogo di conclusione
Cells(ActiveCell.Row, 7) = IIf(optCasaUfficio, "Dal cliente", "") + IIf(optCorrispondenza, " _
Corrispondenza", "") + IIf(optUfficioMobiliare, "Alla Mobiliare", "")
'Premio vecchio
Cells(ActiveCell.Row, 10) = txtVecchioPremioNetto.Value
'Premio nuovo
Cells(ActiveCell.Row, 11) = txtNuovoPremioNetto.Value
'Disdetta annuale
Cells(ActiveCell.Row, 13) = IIf(optDisdettaSI, "SI", "") + IIf(optDisdettaNo, "NO", "")
'Conto corrente
Cells(ActiveCell.Row, 14) = IIf(optSiConto, "SI", "") + IIf(optNoConto, "NO", "") + IIf( _
optGiaConto, "GIÀ", "")
'Dati giovani
Cells(ActiveCell.Row, 15) = IIf(optGiovaniSi, "SI", "") + IIf(optGiovaniNo, "NO", "") + IIf( _
optGiovaniGiaComunicato, "GIÀ", "")
'Dati conorrenza
Cells(ActiveCell.Row, 16) = IIf(optConcorrenzaSi, "SI", "") + IIf(optConcorrenzaNo, "NO", "" _
)
Dim i As Integer, arrConcl As Variant
arrConcl = Array(optConclusione2.Value, optConclusione3.Value, optConclusione5.Value)
'ABG MobiCar
For i = 2 To 0 Step -1
If arrOptConcl(i) = True Then Exit For
Next
i = Application.Min(1, i + 1)
Cells(ActiveCell.Row, 9) = OptMobiCar.Value * -i
Cells(ActiveCell.Row, 8) = OptMobiCar.Value * optConclusione1.Value
'Cells(ActiveCell.Row, 8) = IIf(OptMobiCar.Value = True And optConclusione1.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione2.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione3.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMobiCar.Value = True And optConclusione5.Value = True, 1, 0)
'ABG MobiTour
'Cells(ActiveCell.Row, 8) = IIf(OptMobiTour.Value = True And optConclusione1.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTour.Value = True And optConclusione2.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTour.Value = True And optConclusione3.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTour.Value = True And optConclusione5.Value = True, 1, 0) _
'ABG MAC
'Cells(ActiveCell.Row, 8) = IIf(OptMac.Value = True And optConclusione1.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMac.Value = True And optConclusione2.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMac.Value = True And optConclusione3.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMac.Value = True And optConclusione5.Value = True, 1, 0)
'ABG Lainf
'Cells(ActiveCell.Row, 8) = IIf(OptLainf.Value = True And optConclusione1.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptLainf.Value = True And optConclusione2.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptLainf.Value = True And optConclusione3.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptLainf.Value = True And optConclusione5.Value = True, 1, 0)
'ABG MobiSana
'Cells(ActiveCell.Row, 8) = IIf(OptMobiSana.Value = True And optConclusione1.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiSana.Value = True And optConclusione2.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiSana.Value = True And optConclusione3.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiSana.Value = True And optConclusione5.Value = True, 1, 0) _
'ABG MobiLife
'Cells(ActiveCell.Row, 8) = IIf(OptMobiLifeProposta.Value = True And optConclusione1.Value =  _
True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptMobiLifeProposta.Value = True And optConclusione2.Value =  _
True, 1, 0)
'ABG TS
'Cells(ActiveCell.Row, 8) = IIf(OptTS.Value = True And optConclusione1.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptTS.Value = True And optConclusione2.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptTS.Value = True And optConclusione3.Value = True, 1, 0)
'Cells(ActiveCell.Row, 9) = IIf(OptTS.Value = True And optConclusione5.Value = True, 1, 0)
'If optConclusione4.Value = True Then
'Cells(ActiveCell.Row, 8) = 1
'Cells(ActiveCell.Row, 9) = 1
'End If
'ABG MobiTech
'Cells(ActiveCell.Row, 8) = IIf(OptMobiTech.Value = True And optConclusione1.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTech.Value = True And optConclusione2.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTech.Value = True And optConclusione3.Value = True, 1, 0) _
'Cells(ActiveCell.Row, 9) = IIf(OptMobiTech.Value = True And optConclusione5.Value = True, 1, 0) _
'0effnen Userform MobiCasa und MobiPro
If OptMobiCasa = False And OptMobiPro = False Then
Range("A65536").End(xlUp).Offset(1, 0).Select
ElseIf OptMobiCasa = True Then
usfGMOMobiCasa.Show
ElseIf OptMobiPro = True Then
usfGMOMobiPro.Show
Else
Range("A65536").End(xlUp).Offset(1, 0).Select
End If
Exit Sub
Fehler:
Unload Me
End Sub


Anzeige
AW: Optionbuttons müssen einen Wert wiedergeben
08.12.2008 15:01:00
Thierry
Hallo
Ich habe eine Lösung gefunden. Vielen Dank.
Gruss. Thierry
If OptMobiCar.Value = True And optConclusione1.Value = True Then
Cells(ActiveCell.Row, 8) = 1
Cells(ActiveCell.Row, 9) = 0
ElseIf OptMobiCar.Value = True And optConclusione2.Value = True Then
Cells(ActiveCell.Row, 8) = 0
Cells(ActiveCell.Row, 9) = 1
ElseIf OptMobiCar.Value = True And optConclusione3.Value = True Then
Cells(ActiveCell.Row, 8) = 0
Cells(ActiveCell.Row, 9) = 1
ElseIf OptMobiCar.Value = True And optConclusione5.Value = True Then
Cells(ActiveCell.Row, 8) = 0
Cells(ActiveCell.Row, 9) = 1
End If
Anzeige
AW: Optionbuttons müssen einen Wert wiedergeben
08.12.2008 19:54:56
Gerd
Hallo Thierry,
falls es dich noch interessiert. Da war ein Fehlerteufelchen drin. Die Berichtigung ist fett markiert.
Dim i As Integer, arrConcl As Variant
arrConcl = Array(optConclusione2.Value, optConclusione3.Value, optConclusione5.Value)
For i = 2 To 0 Step -1
If arrConcl(i) = True Then Exit For
Next
i = Application.Min(1, i + 1)
Cells(ActiveCell.Row, 9) = OptMobiCar.Value * -i
Cells(ActiveCell.Row, 8) = OptMobiCar.Value * optConclusione1.Value
Gruß Gerd

82 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige