Using TextBox to AutoFilter

  • Thread starter Thread starter salihyil
  • Start date Start date
S

salihyil

Hi Guys

i have 200 learner with their details.
A1:USername
B1: Access Date
C1:Time
D1:Period

i want to Create UserForm because end-user wants it. and i would lik
to use TextBox to Autofilter by Username.

when end-user enters username; all username details shoudl b
filtered.

i wish u guys can help me

i just need VB Codes.

thank
 
Sub Macro1()
Dim rng as Range
if Activesheet.AutoFilterMode then
Activesheet.AutofilterMode = False
End If
Set rng = Range("A1").CurrentRegion
rng.AutoFilter Field:=1, Criteria1:=Userform1.Textbox1
End Sub
 
Dear Tom Ogilvy

i have tried the function u have sent me. i have been trying it for 3
min but i could not do it.

i m little bit novice. can u explain little bit more. i sorry fo
taking ur time.

do i need to link text box to cell A1?

if u have time can u explain littbit mmore

Thank
 
I had my data on Sheet2, starting with the headers in A1, data below (no
blank rows).

I created a userform with a two textboxes and a command button. I put this
code in the userform module:

Private Sub TextBox1_AfterUpdate()
Dim rng As Range
With Worksheets("Sheet2")
If .AutoFilterMode Then
.AutoFilterMode = False
End If
Set rng = .Range("A1").CurrentRegion
rng.AutoFilter Field:=1, Criteria1:=UserForm1.TextBox1
End With
End Sub

I displayed the userform and put in a value that matched a value in column 1
of the data into Textbox1 and tabbed to the next control. The date was
filtered to display only rows that contained that value in column 1.

Change references like Userform1, Textbox1 and Sheet2 (and range A1) to
match you configuration/controls/sheets/layout.
 
Back
Top