Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox Permission Denied

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
HI,

I am using a textbox to enter a value and a list box is then filtered on the data entered in the textbox, it works fine the first time when I run through the userform, then I always get a permission denied error in this code

Code:
Private Sub FilterList(iCtrl As Long, sText As String)
Dim iRow As Long
Dim sCrit As String
sCrit = "*" & UCase(sText) & "*"
With Me.Listbox1
Sheets("Source Data").Activate
Me.Listbox1.Clear
filfin = Range("d5").End(xlDown).Row 'here is the error
Me.Listbox1.List = Range("d5:d" & filfin).Value

For iRow = .ListCount - 1 To 0 Step -1
If Not UCase(.List(iRow, iCtrl)) Like sCrit Then
.RemoveItem iRow
End If
Next iRow
End With
End Sub

Code:
filfin = Range("d5").End(xlDown).Row

I am placing the list for the listbox by replacing the entries in the column in the source data sheet, by using advance filter on the input sheet and then copying over the new list.

I am at a loss as to why I get the permission denied after I enter a record on the sheet1.



Hope this is of use, Rob.[yoda]
 
has anyone got an ideas on this, as this really confusing me.

Hope this is of use, Rob.[yoda]
 



maybe...
Code:
filfin = [b]Worksheets("YOUR SHEET NAME").[/b]Range("d5").End(xlDown).Row

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top