DB73
Board Regular
- Joined
- Jun 7, 2022
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- 2016
- 2010
- 2007
- Platform
- Windows
- Mobile
- Web
Hi,
i try to populate a listbox from a table (table25)
i want headers but i only want the listbox populated from the 3th row
so in my search on the big www i found that i can add a second listbox and use this as a header and the 1st one only populating with table items without the header
i put this code in the userform;
this seems to work as i run the code...but...only with the table sheet open.
when i open another sheet and run the code, the 2nd listbox (header) uses the rowsource of that sheet.
for me its really strange because i had the rowsource as the sheet where the table is on.
so, just 2 questions;
can i populate and use only 1 listbox with headers from table and than only see the lsit from the 3th row (i want the data from the 2nd row safe so nobody can delete it bcause thy cant see it)
or ist it better to use 2 listboxes...but how to populate only the header or first row.
i hope i made it a bit clear what i mean...english is not my native language
thanks in advance
i try to populate a listbox from a table (table25)
i want headers but i only want the listbox populated from the 3th row
so in my search on the big www i found that i can add a second listbox and use this as a header and the 1st one only populating with table items without the header
i put this code in the userform;
VBA Code:
Dim ws1 As Worksheet, rng1 As Range
Set ws1 = Sheets("adressen")
Set rng1 = ws1.Range("A2:I" & ws1.Range("A" & ws1.Rows.Count).End(xlUp).Row)
With Me.ListBox1
.BorderStyle = 1
.BorderColor = &H80000012
.BackColor = &H80FFFF
.ColumnHeads = False
.ColumnCount = rng1.Columns.Count
.ColumnWidths = "140;130;35;65;100;45;90;85;50"
.RowSource = rng1.Parent.Name & "!" & rng1.Resize(rng1.Rows.Count - 1).Offset(1).Address
End With
With Me.ListBox2
.BorderStyle = 1
.BorderColor = &H80000012
.BackColor = &H80FFFF
.ColumnHeads = True
.ColumnCount = Columns.Count
.ColumnWidths = "140;130;35;65;100;45;90;85;50"
.RowSource = Sheets("adressen").Range("A1:I1").Address
End With
End Sub
this seems to work as i run the code...but...only with the table sheet open.
when i open another sheet and run the code, the 2nd listbox (header) uses the rowsource of that sheet.
for me its really strange because i had the rowsource as the sheet where the table is on.
so, just 2 questions;
can i populate and use only 1 listbox with headers from table and than only see the lsit from the 3th row (i want the data from the 2nd row safe so nobody can delete it bcause thy cant see it)
or ist it better to use 2 listboxes...but how to populate only the header or first row.
i hope i made it a bit clear what i mean...english is not my native language
thanks in advance