+ Reply to Thread
Results 1 to 2 of 2

Comboxes

  1. #1
    Angeliki
    Guest

    Comboxes

    Hi,
    I have a combobox with 3 options. When i choose an option i want to write me
    the
    option in the cell (6,5). although it works for the second and third option
    (Non Residential and combined)
    it does not work for the first one (Residential). Here it is my code. Could
    you please tell me what is wrong?

    If ComboBox3.ListIndex = 0 Then
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Residential"
    End If

    If ComboBox3.ListIndex = 1 Then
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Non Residential"

    Else
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Combined"

    End If

    Thanks in advamce
    Angeliki



  2. #2
    Tom Ogilvy
    Guest

    Re: Comboxes

    You first test for zero. So the cell receive Residential or nothing. Then
    regardless, you
    then test for 1 and if it isn't 1 you treat it as Combined. So residential
    is overwritten in this step. Make your checks exclusive so only one action
    is performed:

    If ComboBox3.ListIndex = 0 Then
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Residential"
    ElseIf ComboBox3.ListIndex = 1 Then
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Non Residential"

    Else
    Worksheets("OUTPUT_CAT").Activate
    Cells(6, 5) = "Combined"

    End If


    --
    Regards,
    Tom Ogilvy


    "Angeliki" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I have a combobox with 3 options. When i choose an option i want to write

    me
    > the
    > option in the cell (6,5). although it works for the second and third

    option
    > (Non Residential and combined)
    > it does not work for the first one (Residential). Here it is my code.

    Could
    > you please tell me what is wrong?
    >
    > If ComboBox3.ListIndex = 0 Then
    > Worksheets("OUTPUT_CAT").Activate
    > Cells(6, 5) = "Residential"
    > End If
    >
    > If ComboBox3.ListIndex = 1 Then
    > Worksheets("OUTPUT_CAT").Activate
    > Cells(6, 5) = "Non Residential"
    >
    > Else
    > Worksheets("OUTPUT_CAT").Activate
    > Cells(6, 5) = "Combined"
    >
    > End If
    >
    > Thanks in advamce
    > Angeliki
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1