Last Display on userform to a Listbox

abbas50

Board Regular
Joined
Dec 6, 2019
Messages
51
Office Version
  1. 2016
Platform
  1. Windows
VBA Code:
lstdisplay.ColumnCount = 15
lstdisplay.RowSource = "A1:O600000"

So when i do this it Displays everything on the sheet i am at i want to adjust that and when i use the userform it shows last 10 or 15 entries only and on the active sheet from userform any help?
 
my userform is a data entry form with multiple sheets i have accomplished to do that and when i enter my data it goes to the sheet i want with every option i need
saying that i just need for my last entries to show in a listbox

You can upload your file to the cloud and in the sheets you explain what you need.

You could upload a copy of your file to a free site such www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
This will remove the items from the listbox and the active sheet.
VBA Code:
Private Sub CommandButton3_Click()
    Dim i As Long
    With Me.lstdisplay
        For i = .ListCount - 1 To 0 Step -1
            If .Selected(i) Then
                Range("A" & Rows.Count).End(xlUp).Offset(-.ListCount + i + 1).EntireRow.Delete
                .RemoveItem (i)
            End If
        Next i
    End With
End Sub
 
Upvote 0
And so by looking at the listbox how will we know what sheet this data in the listbox came from?
there is a Combobox with a country name in it so we will know its from the sheet name coz sheet name and data has the country name thats why my code has multisheet code i select from userform and it goes there ! thats what im trying to say :/
 
Upvote 0
I would like it when users are asked to:
You can upload your file to the cloud and in the sheets you explain what you need.
That the eventual answer be posted here in the forum so others here can see the final code that worked.
 
Upvote 0
This will delete the rows from the sheet selected in the combo
Rich (BB code):
Private Sub CommandButton3_Click()
    Dim i As Long
    If Me.ComboBox1.Value = "" Then Exit Sub
    With Me.Lstdisplay
        For i = .ListCount - 1 To 0 Step -1
            If .Selected(i) Then
                Sheets(Me.ComboBox1.Value).Range("A" & Rows.Count).End(xlUp).Offset(-.ListCount + i + 1).EntireRow.Delete
                .RemoveItem (i)
            End If
        Next i
    End With
End Sub
Change the combo name in red to suit
 
Last edited:
Upvote 0
Thanks for the info i did what you suggested :)
You can upload your file to the cloud and in the sheets you explain what you need.

You could upload a copy of your file to a free site such www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0
I would like it when users are asked to:
You can upload your file to the cloud and in the sheets you explain what you need.

That the eventual answer be posted here in the forum so others here can see the final code that worked.

Of course the answer will be here, but I still don't understand what the OP needs.
If the OP already has the answer, then the file is no longer necessary.
I'm just trying to help. ?
 
Upvote 0
@abbas50
Not sure if you saw post#25 as we posted at the same time
 
Upvote 0
@abbas50
Not sure if you saw post#25 as we posted at the same time
im trying it and its not working it keeps deleting the last 50 rows dont know why and it still debugging when im on another sheet :( this is killing me lol
 
Upvote 0
Of course the answer will be here, but I still don't understand what the OP needs.
If the OP already has the answer, then the file is no longer necessary.
I'm just trying to help. ?
thank you so much for trying to help me i know im a newbie at coding but i need to make my life easier :P ty so much
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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