please anyone help me out
i want to delete the rows is listbox , in which status column is empty
only in listbox not in sheet...
here i attached the file
please anyone help me out
i want to delete the rows is listbox , in which status column is empty
only in listbox not in sheet...
here i attached the file
Last edited by supmk; 04-14-2021 at 08:29 AM.
Hi supmk,
when I downloaded the sample I didn`t expect the opening to throw exceptions all over the place...
First of all: is it really a good idea to give a rowsource which should be a conbstant and then delete unwanted rows? Wouldn´t it be better to just load the rows that match what you are looking for?
After I made the UserForm starting for my system I added a frame and three optionbuttons inside that frame named opt1 (All), opt2 (Open) and opt3 (in Progress) as well as a commandbutton for unloading the UF called Unload Me. The code for the Initialize and CommandButton looks like this:
The code for the OptionButtons:![]()
Private Sub cmdCancel_Click() Unload Me End Sub Private Sub UserForm_Initialize() opt1.Value = True End Sub
All three OptionButtons call the same prcedure behind the UserForm:![]()
Private Sub opt1_Click() Dim lngArray As Long Dim myArray() With ThisWorkbook.Sheets("Sheet1") lngArray = WorksheetFunction.CountA(.Range("A2", .Range("A" & .Rows.Count).End(xlUp))) + 1 ReDim myArray(0 To lngArray, 0 To 5) End With FillArray "opt1", myArray() With Me.ListBox1 .Clear .ColumnCount = 6 .ColumnWidths = "80 pt;100 pt;100 pt;100 pt;100 pt;100 pt" .List() = myArray End With End Sub Private Sub opt2_Click() Dim lngArray As Long Dim myArray() With ThisWorkbook.Sheets("Sheet1") lngArray = WorksheetFunction.CountBlank(.Range("E2", .Range("E" & .Rows.Count).End(xlUp))) + 1 ReDim myArray(0 To lngArray, 0 To 5) End With FillArray "opt2", myArray() With Me.ListBox1 .Clear .ColumnCount = 6 .ColumnWidths = "80 pt;100 pt;100 pt;100 pt;100 pt;100 pt" .List() = myArray End With End Sub Private Sub opt3_Click() Dim lngArray As Long Dim myArray() With ThisWorkbook.Sheets("Sheet1") lngArray = WorksheetFunction.CountA(.Range("E2", .Range("R" & .Rows.Count).End(xlUp))) + 1 ReDim myArray(0 To lngArray, 0 To 5) End With FillArray "opt3", myArray() With Me.ListBox1 .Clear .ColumnCount = 6 .ColumnWidths = "80 pt;100 pt;100 pt;100 pt;100 pt;100 pt" .List() = myArray End With End Sub
As you may see in attached pics I aded the headers to the first entry of the array.![]()
Private Sub FillArray(strOption As String, myArray As Variant) Dim lngRow As Long Dim lngColumn As Long Dim lngCounter As Long With ThisWorkbook.Sheets("Sheet1") For lngColumn = 0 To 5 myArray(0, lngColumn) = CStr(.Cells(1, lngColumn + 1).Value) Next lngColumn For lngRow = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row Select Case strOption Case "opt1" lngCounter = lngCounter + 1 For lngColumn = 0 To 5 myArray(lngCounter, lngColumn) = CStr(.Cells(lngRow, lngColumn + 1).Value) Next lngColumn Case "opt2" If .Cells(lngRow, "E").Value = "" Then lngCounter = lngCounter + 1 For lngColumn = 0 To 5 myArray(lngCounter, lngColumn) = CStr(.Cells(lngRow, lngColumn + 1).Value) Next lngColumn End If Case "opt3" If .Cells(lngRow, "E").Value <> "" Then lngCounter = lngCounter + 1 For lngColumn = 0 To 5 myArray(lngCounter, lngColumn) = CStr(.Cells(lngRow, lngColumn + 1).Value) Next lngColumn End If Case Else MsgBox "Not an expected value, programm aborted.", vbInformation, "Unexpected Value paased" End End Select Next lngRow End With End Sub
HTH,
Holger
Use Code-Tags for showing your code: [code] Your Code here [/code]
Please mark your question Solved if there has been offered a solution that works fine for you
sir its fine,
but i need the operation should be done in listbox only. i don't want to call or take reference of sheet
Administrative Note:
Welcome to the forum.
We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.
Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.
(Note: this requirement is not optional. No help to be offered until the link is provided.)
sit this is a link where i posted a thread , please do help me sir
https://www.ozgrid.com/forum/index.p...ws-of-listbox/
initially i have no idea about this... and sorry for that i will not repeat this..
please forgive me
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks