By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

Selected found items in listbox to found cells in excel

P: 2
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:=xlValues)
If Not foundcell Is Nothing Then
FirstAddress = foundcell.Address
'View
ListBox1.Clear
Do
foundcell(1, 1).Activate
foundcell(1, 3).Value = TextBox1
foundcell(1, 4).Value = TextBox2

'Fill list box

ListBox1.AddItem foundcell(1, 2).Value

Set foundcell = .FindNext(foundcell)
Loop While Not foundcell Is Nothing And foundcell.Address <> 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:=xlValues)
If Not foundcell Is Nothing Then
FirstAddress = foundcell.Address
'View
foundcell(1, 1).Activate
Do
If foundcell(1, 2) = "In" Then


For i = 0 To 10
If ListBox1.Selected(i) = True Then
foundcell(1, 1).Activate = ListBox1.Selected(ListBox1.ListIndex)

End If
Next i

End If

Set foundcell = .FindNext(foundcell)
Loop While Not foundcell Is Nothing And foundcell.Address <> FirstAddress
End If
End With

End If


End Sub
Mar 9 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.