Selected found items in listbox to found cells in excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • savakis
    New Member
    • Mar 2007
    • 2

    Selected found items in listbox to found cells in excel

    Can onyone please help me please.
    I have duplicate items in column A:A which I find via combobox1. These items are placed in listbox1. I then fill in textbox1 and textbox2 for column C and D, and then fill the found cells with some text. This is OK.
    I then have option2 where I am trying to put text in found cells that are only selected in my listbox1 this is set for multiselect.

    The option2 does not work. Can anyone check this out please.
    Savakis


    Private Sub CommandButton2_ Click()

    On Error Resume Next
    'add to all
    If OptionButton1 = True Then
    With Range("A:A")
    Set foundcell = .Find(ComboBox1 .Value, LookIn:=xlValue s)
    If Not foundcell Is Nothing Then
    FirstAddress = foundcell.Addre ss
    'View
    ListBox1.Clear
    Do
    foundcell(1, 1).Activate
    foundcell(1, 3).Value = TextBox1
    foundcell(1, 4).Value = TextBox2

    'Fill list box

    ListBox1.AddIte m foundcell(1, 2).Value

    Set foundcell = .FindNext(found cell)
    Loop While Not foundcell Is Nothing And foundcell.Addre ss <> FirstAddress
    End If
    End With
    End If

    'Add only selected items
    If OptionButton2 = True Then
    On Error Resume Next

    With Range("A:A")
    Set foundcell = .Find(ComboBox1 .Value, LookIn:=xlValue s)
    If Not foundcell Is Nothing Then
    FirstAddress = foundcell.Addre ss
    'View
    foundcell(1, 1).Activate
    Do
    If foundcell(1, 2) = "In" Then


    For i = 0 To 10
    If ListBox1.Select ed(i) = True Then
    foundcell(1, 1).Activate = ListBox1.Select ed(ListBox1.Lis tIndex)

    End If
    Next i

    End If

    Set foundcell = .FindNext(found cell)
    Loop While Not foundcell Is Nothing And foundcell.Addre ss <> FirstAddress
    End If
    End With

    End If


    End Sub
Working...