weltretter
New Member
- Joined
- May 3, 2022
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi everybody,
hope you're all doing great.
I got stuck at my current project and after searching the internet for hours and even days, I have to ask for help on my own?
I've first heard of VBA like 4-5 months ago. Now I'm trying to support my daily business at work and make it easier to handle certain processes.
Due to that my codes are mostly like a puzzle with pieces from different forums all over the web, so please don't be to harsh on me, because I'm pretty sure I'm not using the most efficient and logic ways to solve my problems. But for my requirements it's working (well, until now) ?
So, what's the matter?
While I am populating a listbox from a table there will be multiple empty rows added to the list (on a userform, using VBA).
As you can see in the following screenshot (notice the scrollbar ?)
Listbox populated with empty rows
How's my setup?
-I've got multiple tables in a worksheet
-Every table got renamed to make it easier to find
-You have to enter a number in a textbox and press a button to start the process
-The number accords to one specific table
-Listbox got populated with some data from the columns of this specific table
This is one of the tables the listbox is using as source
The piece of code which is used to populate the listbox
Can somebody please tell me where those empty rows (in this case there are 25 empty rows) came from?
Best regards from Germany
hope you're all doing great.
I got stuck at my current project and after searching the internet for hours and even days, I have to ask for help on my own?
I've first heard of VBA like 4-5 months ago. Now I'm trying to support my daily business at work and make it easier to handle certain processes.
Due to that my codes are mostly like a puzzle with pieces from different forums all over the web, so please don't be to harsh on me, because I'm pretty sure I'm not using the most efficient and logic ways to solve my problems. But for my requirements it's working (well, until now) ?
So, what's the matter?
While I am populating a listbox from a table there will be multiple empty rows added to the list (on a userform, using VBA).
As you can see in the following screenshot (notice the scrollbar ?)
Listbox populated with empty rows
How's my setup?
-I've got multiple tables in a worksheet
-Every table got renamed to make it easier to find
-You have to enter a number in a textbox and press a button to start the process
-The number accords to one specific table
-Listbox got populated with some data from the columns of this specific table
This is one of the tables the listbox is using as source
VBA Code:
[/SIZE]
TableName = "Tabelle" + TextBox1.Value
Set Table = ActiveWorkbook.Sheets("Tabelle1").ListObjects(TableName)
TableRows = Table.Range.Rows.Count
TextBox2.Value = Table.DataBodyRange.Cells(1, Table.ListColumns("Name").Index)
For i = 0 To TableRows
With ListBox1
.ColumnCount = 4
.ColumnWidths = "80;80;70;20"
.AddItem
.List(i, 0) = Table.DataBodyRange.Cells(i, Table.ListColumns("TZL").Index)
.AddItem
.List(i, 1) = Table.DataBodyRange.Cells(i, Table.ListColumns("Mtr").Index)
.AddItem
.List(i, 2) = Table.DataBodyRange.Cells(i, Table.ListColumns("Plc").Index)
.AddItem
.List(i, 3) = Table.DataBodyRange.Cells(i, Table.ListColumns("Verfügbar").Index)
End With
Next
[SIZE=3]
Can somebody please tell me where those empty rows (in this case there are 25 empty rows) came from?
Best regards from Germany