ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listbox Question (https://www.excelbanter.com/excel-programming/324918-listbox-question.html)

Greg B[_4_]

Listbox Question
 
I have userform4 where I have put a command button and listbox on it, this
is connected to a sheet called Hidden.

I want to allow the user to select the text in the userbox and click on the
command button to delete that certain entry on the worksheet.

Is this possible, How to I acheive this to happen.

Thanks in advance

Greg



Dave Peterson[_5_]

Listbox Question
 
This worked ok for me:

Option Explicit
Private Sub CommandButton1_Click()
If Me.ListBox1.ListIndex -1 Then
With Worksheets("Hidden")
.Rows(Me.ListBox1.ListIndex + 1).Delete
Call UserForm_Initialize
End With
End If
End Sub
Private Sub UserForm_Initialize()
Dim myArray As Variant

With Worksheets("Hidden")
myArray = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)).Value
If IsArray(myArray) Then
'ok
Else
myArray = Array(myArray)
End If
End With
Me.ListBox1.List = myArray
End Sub

My list was in A1:Axx on a worksheet called Hidden.

Greg B wrote:

I have userform4 where I have put a command button and listbox on it, this
is connected to a sheet called Hidden.

I want to allow the user to select the text in the userbox and click on the
command button to delete that certain entry on the worksheet.

Is this possible, How to I acheive this to happen.

Thanks in advance

Greg


--

Dave Peterson


All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com