Hi,
I'm a complete newbie to VBA and have been follwing a tutorial to build a simple Excel/VBA database. I have all working great, but there is one part where I need some help if possible...
There is a form that does the data-entry and on the form it has a listbox to display the data. When data is added, it gets stored in a worksheet, and the form displays this data in a listbox.
In the code, the bit that populates the listbox is:
.lstDatabase.ColumnCount = 15
.lstDatabase.ColumnHeads = True
.lstDatabase.ColumnWidths = "86,90,115,74,65,55,180,45,40,45,110,110,110,0,100"
If iRow > 1 Then
.lstDatabase.RowSource = "Database!A2:O" & iRow
Else
.lstDatabase.RowSource = "Database!A2:O2"
End If
This all works great, but when a person enters a new entry it gets stored in the next available row on the 'database' worksheet, but the listbox shows only the first xx rows that fit on the screen. Is there any way I can tweak this code so that the listbox will display the data in reverse order? So newly entered records will appear at the top of the listbox?
Many thanks
Mark
I'm a complete newbie to VBA and have been follwing a tutorial to build a simple Excel/VBA database. I have all working great, but there is one part where I need some help if possible...
There is a form that does the data-entry and on the form it has a listbox to display the data. When data is added, it gets stored in a worksheet, and the form displays this data in a listbox.
In the code, the bit that populates the listbox is:
.lstDatabase.ColumnCount = 15
.lstDatabase.ColumnHeads = True
.lstDatabase.ColumnWidths = "86,90,115,74,65,55,180,45,40,45,110,110,110,0,100"
If iRow > 1 Then
.lstDatabase.RowSource = "Database!A2:O" & iRow
Else
.lstDatabase.RowSource = "Database!A2:O2"
End If
This all works great, but when a person enters a new entry it gets stored in the next available row on the 'database' worksheet, but the listbox shows only the first xx rows that fit on the screen. Is there any way I can tweak this code so that the listbox will display the data in reverse order? So newly entered records will appear at the top of the listbox?
Many thanks
Mark