list box not showing choices

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
I have a listbox that will show the range containing the choices, but only if the sheet with the range of choices is the active sheet. How to have the list box show the choices no matter what sheet is active. Below is my code for the userform. Form name is "samform". Listbox name is "sambox" The range containing the choices is "samlist"
VBA Code:
Sub show_samform()
samform.Show modal
With samform
    .Height = 300
    .Width = 280
    .Caption = "show_samform"
    With samform.Label1
        .Caption = "Enter"
        .Top = 2
        .Width = 200
        .Height = 30
        .Font.Size = 20
        .Font.Bold = True
        .ForeColor = vbBlue
        .Left = (samform.InsideWidth - .Width) / 2
        .TextAlign = fmTextAlignCenter
    End With
    With samform.Label2
        .Caption = Range("ReportName").Value
        .Top = 32
        .Width = 280
        .Height = 30
        .Font.Size = 20
        .Font.Bold = True
        .ForeColor = vbRed
        .Left = (samform.InsideWidth - .Width) / 2
        .TextAlign = fmTextAlignCenter
    End With
    With samform.Label3
        .Caption = "Samples"
        .Top = 62
        .Width = 200
        .Height = 30
        .Font.Size = 20
        .Font.Bold = True
        .ForeColor = vbBlue
        .Left = (samform.InsideWidth - .Width) / 2
        .TextAlign = fmTextAlignCenter
    End With
    With samform.sambox
        .Top = 102
        .Width = 100
        .Height = 120
        .Left = (samform.InsideWidth - .Width) / 2
        .RowSource = Range("samlist").Address
        .Font.Size = 10
        .Font.Bold = True
        .TextAlign = fmTextAlignCenter
        .MultiSelect = fmMultiSelectMulti
        .SetFocus
    End With
    With samform.samform_but
        .Top = 224
        .AutoSize = True
        .Caption = "OK"
        .Font.Size = 14
        .Font.Bold = True
        .ForeColor = vbBlack
        .Left = (samform.InsideWidth - .Width) / 2
    End With
End With
Do While samform.Visible
DoEvents
Loop
End Sub

Thanks for any help
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
What sheet is the list on?
 
Upvote 0
In that case try
VBA Code:
.RowSource = Sheets("Header").Range("samlist").Address(, , , 1)
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top