lists without listbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a that I can create a list (and add to it) without creating a listbox?

Private Sub CommandOK_Click()

Dim i As Integer
Dim sStr As String

Select Case True
Case CheckMachine.Value

Range("A1").Value = "Marketing"

If CheckMNew.Value = True Then
ListBAdd.AddItem "ProductManager"

ElseIf CheckMFFF.Value = True Then
ListBAdd.AddItem "ProductManager"
ListBAdd.AddItem "Director of Engineering"
ElseIf CheckMWarranty.Value = True Then
ListBAdd.AddItem "Director of Engineering"
ListBAdd.AddItem "Director of Service"
ListBAdd.AddItem "Quality Manager"
ElseIf CheckMDisc.Value = True Then
ListBAdd.AddItem "ProductManager"
End If
End Select

With ListBAdd
For i = 0 To .ListCount - 1
If i <> .ListCount - 1 Then
sStr = sStr & .List(i) & " / "
Else
sStr = sStr & .List(i)
End If
Next i
End With
Range("A4").Value = sStr

End Sub
 
a,

You could make the listbox invisible or
you could use a Collection or Dictionary object or
you could use an array...
'-------------------
Sub MakeListUsingArray()
Dim strArray() As String
Dim strNames As String
Dim N As Long
ReDim strArray(1 To 3)

strArray(1) = "Larry"
strArray(2) = "Moe"
strArray(3) = "Curly"

For N = 1 To 3
strNames = strNames & strArray(N) & "/ "
Next

Range("A4").Value = strNames
End Sub
'---------------

Jim Cone
San Francisco, USA



Is there a that I can create a list (and add to it) without creating a listbox?

Private Sub CommandOK_Click()

Dim i As Integer
Dim sStr As String
Select Case True
Case CheckMachine.Value
Range("A1").Value = "Marketing"

If CheckMNew.Value = True Then
ListBAdd.AddItem "ProductManager"

ElseIf CheckMFFF.Value = True Then
ListBAdd.AddItem "ProductManager"
ListBAdd.AddItem "Director of Engineering"
ElseIf CheckMWarranty.Value = True Then
ListBAdd.AddItem "Director of Engineering"
ListBAdd.AddItem "Director of Service"
ListBAdd.AddItem "Quality Manager"
ElseIf CheckMDisc.Value = True Then
ListBAdd.AddItem "ProductManager"
End If
End Select

With ListBAdd
For i = 0 To .ListCount - 1
If i <> .ListCount - 1 Then
sStr = sStr & .List(i) & " / "
Else
sStr = sStr & .List(i)
End If
Next i
End With
Range("A4").Value = sStr
End Sub
 
Back
Top