Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #10  
Old 12-23-2022, 10:18 PM
gmayor's Avatar
gmayor gmayor is offline Userform listbox reading from external excel Windows 10 Userform listbox reading from external excel Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,145
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform listbox reading from external excel Yet another Multi-Select Listbox in Userform question Javir Word VBA 4 09-24-2019 01:01 AM
Dynamic Userform multiselect listbox populate trevorc Excel Programming 1 12-03-2018 02:49 PM
How do I code ListBox and DatePicker in UserForm? - Word 2013 ickelly Word VBA 4 08-05-2015 04:07 PM
This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel Programming 14 08-18-2014 08:14 PM
Userform listbox reading from external excel This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel 1 08-08-2014 09:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2026 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft