View Single Post
 
Old 12-23-2022, 10:18 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Unfortunately you can't adapt the code as you have done, with regard to the list box. If you want to insert multiple values from the list box then you must add each selected value to the bookmark. There are a number of ways of doing this, but the simplest is to add them to a text string and then add the text string to the bookmark e.g. as follows.

Don't forget to declare the string strText in the DIM statements at the top of the macro!

I assume that you removed any reference to the text box from the userform code.Debug > Compile Project should reveal any glaring coding errors.

Have a good Christmas.

Code:
.Show
        If .Tag = 1 Then    'OK button pressed
            With .ListBox1
                'locate the selected items from the list box and add to a string
                For i = 0 To .ListCount - 1
                    If .Selected(i) = True Then
                        If strText = "" Then
                            strText = strText & .List(i)
                        Else
                            strText = strText & vbCr & .List(i)
                        End If
                    End If
                Next i
            End With
            FillBM "BM1", strText
        End If
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote