PDA

View Full Version : Long if statements with numbers.



WMO
12-07-2018, 12:19 AM
Hello,

i am rather new to vba. Im used to R a bit. So I know that loops are computationally ineficient. Since Im programming a small database in excel/vba I was wondering if there is a function I can use for a statement like this:

Berechnungsgrundlagen!E42;WENN(D13=Berechnungsgrundlagen!D43;Berechnungsgru ndlagen!E43;WENN(D13=Berechnungsgrundlagen!D44;Berechnungsgrundlagen!E44;WE NN(D13=Berechnungsgrundlagen!D45;Berechnungsgrundlagen!E45;WENN(D13=Berechn ungsgrundlagen!D46;Berechnungsgrundlagen!E46;WENN(D13=Berechnungsgrundlagen !D47;Berechnungsgrundlagen!E47;)))))))


--> I have not found any suitable function. Therefore I decided to try out the loop solution: Howeer I run into Problems there as well. Therefore I add another question to this thread: What is wrong with the following code:


If ComboBox3 = "Strom" Then ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 1
ElseIf ComboBox3 = "Pellets" Then ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 72.72
ElseIf ComboBox3 = "St?ckholz" Then ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 71.64

End If

Best Matthias

Paul_Hossler
12-07-2018, 05:39 AM
Try separate lines




If ComboBox3 = "Strom" Then
ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 1
ElseIf ComboBox3 = "Pellets" Then
ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 72.72
ElseIF ComboBox3 = "St?ckholz" Then
ActiveSheet.Cells(intErsteLeereZeile, 5).Value = 71.64
End If