Hallo Werner,
habe deinen Code wie folgt an meine Benennungen angepasst. Musste noch eine Spalten des Ausgangsmaterials ändern bzw hinzufügen:
Private Sub optbottom_Click()
'Textbox1 = txtcleaningtime
'TExtbox2 = txthireloss
'textbox3 = txtcleaningcosts
'TExtbox4 = txttotalcosts
'Checkbox1 = optbottom
'Checkbox2 = optsides
'ComboBox1 = cboVslName
With Worksheets("Vsl details") 'Blattname anpassen
Me.txttotalcosts = ""
'Daten aus Spalte L (cleaning flat bottom) in Textbox
If Me.optbottom And Not Me.optsides And Me.cboVslName.ListIndex > -1 Then
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:L"), 12, False), "0.00")
'Daten aus Spalte O (hire loss for cleaning flat bottom) in Textbox 2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:O"), 15, False), "0.00")
Me.txtcleaningcosts = ""
ElseIf Me.optsides And Not Me.optbottom And Me.cboVslName.ListIndex > -1 Then
'Daten aus Spalte M in txtcleaningtime
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:M"), 13, False), "0.00")
'Daten aus Spalte P in txthireloss
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:P"), 16, False), "0.00")
'Daten aus Spalte R in txtcleaningcosts
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:R"), 18, False), "0.00")
ElseIf Me.optbottom And Me.optsides And Me.cboVslName.ListIndex > -1 Then
'Daten aus Spalte N in txtcleaningtime
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:N"), 14, False), "0.00")
'Daten aus Spalte Q in txthireloss
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:Q"), 17, False), "0.00")
'Daten aus Spalte T in txtcleaningcosts
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:S"), 19, False), "0.00")
Else
Me.txtcleaningtime = ""
Me.txthireloss = ""
Me.txtcleaningcosts = ""
Me.txttotalcosts = ""
End If
End With
End Sub
Private Sub optsides_Click()
'Textbox1 = txtcleaningtime
'TExtbox2 = txthireloss
'textbox3 = txtcleaningcosts
'TExtbox4 = txttotalcosts
'Checkbox1 = optbottom
'Checkbox2 = optsides
'ComboBox1 = cboVslName
With Worksheets("Vsl details") 'Blattname anpassen
Me.txttotalcosts = ""
If Me.optsides And Not Me.optbottom And Me.cboVslName.ListIndex > -1 Then
'Daten aus Spalte M in Textbox1
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:M"), 13, False), "0.00")
'Daten aus Spalte P in Textbox2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:P"), 16, False), "0.00")
'Daten aus Spalte R in Textbox3
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:R"), 18, False), "0.00")
ElseIf Me.optbottom And Not Me.optsides And Me.cboVslName.ListIndex > -1 Then
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:L"), 12, False), "0.00")
'Daten aus Spalte O in Textbox
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:O"), 15, False), "0.00")
Me.txtcleaningcosts = ""
ElseIf Me.optsides And Me.optbottom And Me.cboVslName.ListIndex > -1 Then
'Daten aus Spalte N in Textbox1
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:N"), 14, False), "0.00")
'Daten aus Spalte Q in Textbox2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:Q"), 17, False), "0.00")
'Daten aus Spalte T in Textbox3
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:T"), 20, False), "0.00")
Else
Me.txtcleaningtime = ""
Me.txthireloss = ""
Me.txtcleaningcosts = ""
Me.txttotalcosts = ""
End If
End With
End Sub
Private Sub cboVslName_Change()
'Textbox1 = txtcleaningtime
'TExtbox2 = txthireloss
'textbox3 = txtcleaningcosts
'TExtbox4 = txttotalcosts
'Checkbox1 = optbottom
'Checkbox2 = optsides
'ComboBox1 = cboVslName
With Worksheets("Vsl details") 'Blattname anpassen
If Me.cboVslName = "" Then
Me.txtcleaningtime = ""
Me.txthireloss = ""
Me.txtcleaningcosts = ""
Me.txttotalcosts = ""
Exit Sub
End If
Me.txttotalcosts = ""
If Me.optbottom And Not Me.optsides Then
'Daten aus Spalte L in Textbox1
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:L"), 12, False), "0.00")
'Daten aus Spalte O in Textbox2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:O"), 15, False), "0.00")
Me.txtcleaningcosts = ""
ElseIf Me.optsides And Not Me.optbottom Then
'Daten aus Spalte M in Textbox1
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:M"), 13, False), "0.00")
'Daten aus Spalte P in Textbox2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:P"), 16, False), "0.00")
'Daten aus Spalte R in Textbox3
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:R"), 18, False), "0.00")
ElseIf Me.optbottom And Me.optsides Then
'Daten aus Spalte N in Textbox1
Me.txtcleaningtime = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:N"), 14, False), "0.00")
'Daten aus Spalte Q in Textbox2
Me.txthireloss = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:Q"), 17, False), "0.00")
'Daten aus Spalte T in Textbox3
Me.txtcleaningcosts = Format(WorksheetFunction.VLookup(Me.cboVslName, .Range("A:T"), 20, False), "0.00")
End If
End With
End Sub
Private Sub cmdCalculate_Click()
'Textbox1 = txtcleaningtime
'TExtbox2 = txthireloss
'textbox3 = txtcleaningcosts
'TExtbox4 = txttotalcosts
'Checkbox1 = optbottom
'Checkbox2 = optsides
'ComboBox1 = cboVslName
If Not Me.optbottom And Not Me.optsides Then
MsgBox "Es wurde keine Auswahl getroffen."
Exit Sub
End If
If Me.optbottom And Not Me.optsides And Me.cboVslName.ListIndex > -1 Then
Me.txttotalcosts = Format(CDbl(Me.txthireloss), "0.00")
'End If
ElseIf Me.optbottom And Me.optsides And Me.cboVslName.ListIndex > -1 Then
Me.txttotalcosts = Format(CDbl(Me.txthireloss) + CDbl(Me.txtcleaningcosts), "0.00")
'End If
ElseIf Me.optsides And Not optbottom And Me.cboVslName.ListIndex > -1 Then
Me.txttotalcosts = Format(CDbl(Me.txthireloss) + CDbl(Me.txtcleaningcosts), "0.00")
Else
MsgBox "Bitte ein Schiff auswählen."
End If
End Sub
Gruß Olli
|