I have a ListBox in a userform that has items populated in it.
What I would like to do is add all of the items to a string seperated by a semicolon.
So far I have the following code:
For i = 0 To Me.lbSend.ListCount - 1
Set strEmail = ws.Range("A:A").Find(What:="Me.lbSend.List(i)", LookAt:=xlWhole, MatchCase:=False, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
strTo = strTo & ";" & strEmail.Offset(0,1).Value
Next i
However, it is not working and I can't quite put my finger on why.
For each item in the list I need to find it in Column A in another worksheet and then add the value in the cell to the right of it to the string.
For anyone else that requires that same answer:
@tigeravatar spotted the mistake and is correct with the following: (No quotes around Me.lbSend.List(i))
For i = 0 To Me.lbSend.ListCount - 1
Set strEmail = ws.Range("A:A").Find(What:=Me.lbSend.List(i), LookAt:=xlWhole, MatchCase:=False, SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
strTo = strTo & ";" & strEmail.Offset(0,1).Value
Next i
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.