Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Listbox.value=null? (Excel 2000)

    I have three list boxes that I would like to test the condition of, if there is a selection I would like it to continue, but if it is not selected I want a MSG function then exit the sub.
    On a command button here's where I need some help, If the value is "NULL" is there another way of testing for that value?

    Private Sub CommandButton1_Click()
    Dim Stxtresponse As String
    Dim OPTV As String
    Dim Stime As String
    Dim SName As String
    Dim x As String
    Stxtresponse = TextBox1.Value
    x = Calendar1.Value
    SName = ListBox1.Value
    If TextBox1.Value = "" Then
    MsgBox "PLEASE INPUT RECORD OF OVERTIME TO ENSURE ACCURATE ACCOUNT OF OVERTIME.", vbExclamation
    Exit Sub
    End If
    If ListBox1.Value = "" Or ListBox2.Value = "" Then
    MsgBox " PLEASE MAKE SELECTION FROM 1 OR BOTH LISTBOXES TO ENSURE ACCURATE ACCOUNT OF OVERTIME."
    Exit Sub
    End If
    Select Case ListBox2.Value '(ListBox2.ListIndex) '''''''Here's where I am having a problem. I'm not sure if my IF STATE IS CORRECT Case "NAME"
    If ListBox3.Value = "" Then
    MsgBox "PLEASE SELECT FROM OVERTIME OPTIONS TIME OPTIONS LISTBOX TO CONTINUE", vbCritical, "PLATE ROOM OVERTIME"
    Exit Sub
    Else
    OPTV = ListBox3.Value
    Sheets("PLATEROOM OVERTIME").Range("A2").Select
    Selection.End(xlToRight).Select
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.Value = x
    ActiveCell.Offset(1, 0).Select
    ActiveCell.Value = SName
    End If


    Thanks,
    Darryl.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Listbox.value=null? (Excel 2000)

    If nothing has been selected in a list box, its ListIndex property is -1, so you can test

    If ListBox1.ListIndex = -1 Or ListBox2.ListIndex = -1 Then

    and

    If ListBox3.ListIndex = -1 Then

  3. #3
    4 Star Lounger
    Join Date
    May 2004
    Location
    Toronto, Ontario, Canada
    Posts
    425
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Re: Listbox.value=null? (Excel 2000)

    Thank You Hans

Posting Permissions

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