Table on a suerform

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
771
Office Version
  1. 365
Platform
  1. Windows
Evening,

I am trying to create a userform to show statistics that are pulled form another spreadsheet.

Is there anyway i can create a table on a userform that will look neat as well as allow me to pull information into it when it is opened via a button?

Many thanks
Gavin
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Good Afternoon,

I am fairly new to VB.
The "listbox" that you suggested can it show the info i have in another spreadsheet.

I need the form to show exactly what the spreadsheet says ( 4 columns & 9 Rows ) It should show how many queries are open on a team etc..

Is there anywhere i can look up how to create a listbox etc....

Many thanks
Gavin
 
Upvote 0
Make a userform with a list box and put this code in the userform's code module
Code:
Private Sub UserForm_Initialize()
    Dim rangeToShow As Range, oneRow As Range
    Dim i As Long
    Set rangeToShow = Sheet1.Range("A1:D7")
    
    With ListBox1
        .ColumnCount = rangeToShow.Columns.Count
        For Each oneRow In rangeToShow.Rows
            .AddItem oneRow.Cells(1, 1).Text
            For i = 1 To .ColumnCount - 1
                .List(.ListCount - 1, i) = oneRow.Cells(1, i + 1).Text
            Next i
        Next oneRow
    End With
End Sub
 
Upvote 0
Mike,

Or without looping:

Code:
Private Sub UserForm_Initialize()
    With Sheet1.Range("A1:D7")
        ListBox1.ColumnCount = .Columns.Count
        ListBox1.List = .Value
    End With
End Sub

or if the columncount is changed at design time:

Code:
Private Sub UserForm_Initialize()
    ListBox1.List = Sheet1.Range("A1:D7").Value
End Sub
 
Upvote 0
Any multi column list box, there are odd instabilities in Mac Excel/VBA.
(Another example, put an event in ThisWorkbook, OK,
remove the code from the event leaving the two lines, Private Sub... & End Sub, OK,
remove those two lines, crash)

Does the multi-column ListBox have the appearance and features that gmazza76 wants?
 
Upvote 0
Table on a userform

AS my data is in another workbook, would i still be able to do this?
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

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