Consulting

Results 1 to 2 of 2

Thread: Long if statements with numbers.

  1. #1
    VBAX Newbie
    Joined
    Dec 2018
    Posts
    2
    Location

    Long if statements with numbers.

    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
    Last edited by WMO; 12-07-2018 at 02:00 AM.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •