• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

retrieve autofilter to listbox

Afarag

Member
Dear,

Please i need support in retrieving the autofilter data to listbox, as when running the code the autofilter is reflecting the the source sheet only but the listbox have the entire range

Code:
Private Sub btn_Redeem_Click()
Application.ScreenUpdating = False
Dim crng As Range

With Sheet2.ListObjects("Table_Source")

Dim LastRow As Long
Dim index As Integer

Dim a As Worksheet
Dim number_of_rows As Long

Set a = ThisWorkbook.Sheets("Deduction")

With a
.Range("B2").AutoFilter Field:=2, Criteria1:="Dec"
.Range("X2").AutoFilter Field:=33, Criteria1:="Marina.Gobran"

number_of_rows = .Range("Y" & .Rows.Count).End(xlUp).Row


ListBox1.AddItem ("Date" & "        Total Deduction      " & " Name ")

For index = 2 To (32500 - 1)
ListBox1.AddItem (a.Cells(index, 1) & "              " & a.Cells(index, 24) & "                " & a.Cells(index, 25))
Next

End With
End With

End Sub

Gratefully,
 
Hi Afarag ,

If possible , when ever your problem pertains to controls , such as in this case a listbox , please upload the workbook with the control(s) ; otherwise , members may suggest reasons which apply in general but not necessarily to your particular case , since for any problem there may be more than one reason.

A lot of time can be spent in suggestions which may or may not help.

If a workbook is uploaded , who ever wants to help can use the workbook to test , which helps eliminate a lot of possibilities , thus giving you a solution faster.

Narayan
 
Hi ,

The VBA Project is protected , and I cannot see any listbox anywhere in the worksheet tabs.

What is to be done ?

Narayan
 
@NARAYANK991 ,

so sorry for confusing the VBA is unprotected now
the workbook have multiple forms, the listbox is lacated at a form that titled: "Rewarding"
this form is called from "LoginUF" , button of "Rewards"

from the Interface you can Hit Agent Login Icon then fill at username field: Marina.Gobran
2nd field: 84109 then hit "Rewards" Button

0


the second screen contain the output worksheet with Marina filtered data and also the form that have the listbox that need to filter the data: "the columns 1,2,33 and 25 in Deduction sheet" with the username and need to use a combobox to filter the month and use it as a criteria also,

0


the URL

http://1drv.ms/1x8oudJ
Gratefully,
 
Last edited:
Back
Top