+ Reply to Thread
Results 1 to 2 of 2

Changing listbox code to work in a userform

Hybrid View

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    Arizona, US
    MS-Off Ver
    Excel 2010
    Posts
    24

    Changing listbox code to work in a userform

    I wanted my listbox to be in my userform. However when I try to code it in the way that makes sense to me I keep throwing this error, "The item with the specified name wasn't found." And highlights:
    Call UserForm1.ListBoxFunction(ar())
    This is the part from the module:
    Call calluserform(ar())
    Function calluserform(ar() As String)
        Call UserForm1.ListBoxFunction
    End Function
    This is the part from the userform:
    Function ListBoxFunction(ar() As String)
    Dim Count As Integer, i As Integer, j As Integer, n As Integer
    Dim SummaryWks As Worksheet
    Dim LB As ListBox
    
    
    Set SummaryWks = Worksheets("Summary")
    Set LB = SummaryWks.OLEObjects("TowerTypeLB").Object
    
    
    Count = 0
    n = 3
    
    For i = 0 To LB.ListCount - 1
        'check if the row is selected and add to count
        If LB.Selected(i) Then Count = Count + 1
    Next i
    
    'based on the above count declare the array
    ReDim ar(Count)
    
    j = 0
    For i = 0 To LB.ListCount - 1
        If LB.Selected(i) Then
            'if selected then store the item from the
            'first column in the array. change 1 to the
            'respective column number
            ar(j) = LB.List(i)
            j = j + 1
        End If
    Next i
    End Function

  2. #2
    Registered User
    Join Date
    06-27-2013
    Location
    Arizona, US
    MS-Off Ver
    Excel 2010
    Posts
    24

    Re: Changing listbox code to work in a userform

    Anyone have any ideas how to go about solving this problem?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Get Data from UserForm (TextBox, ListBox) doesnt work
    By BorisMKD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-15-2014, 05:07 AM
  2. Transfer Data From One Userform Listbox to Another Userform Listbox with 11 columns
    By sparkoft in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-18-2013, 10:54 AM
  3. [SOLVED] listbox.height setup will not work unless code is interrupted
    By Hammer_757 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2012, 08:49 PM
  4. Listbox to Listbox, no duplicates & submitting same UserForm data for each Listbox entry.
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-18-2012, 12:18 PM
  5. Converting listbox code to work with Listview
    By gsurge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-08-2012, 01:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1