[pre]
[/pre]
Code:
A1 B1 C1 D1 L1
Name Name Position Department keyword
The above mentioned cells contain Employee database.
If i mention dept. say "HR" in cell L1, i should get only data relating to HR department.
I have used this with command button (with the below formula).
how do i use it without command button.
Sub LoadData()
Dim rng As Range
Sheets("Sheet1").Range("A1:D14").Clear
Set rng = Sheet2.Cells(1, 1).CurrentRegion
With rng
.AutoFilter 4, Sheets("Sheet1").Buttons(Application.Caller).Caption
.SpecialCells(12).Copy Sheets("Sheet1").Range("A4")
.AutoFilter
End With
End Sub
Private Sub CommandButton2_Click()
LoadData
End Sub