#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Filter Code

I have a large table with employee ids in asscending order
in the third column. An employee id record is not unique,
so there can be many employee records per employee. Using
a filter, I would like to view all the records pertaining
to one employee at a time. Does anyone have sample code
they could share that would allow the filter to advance to
the next employee id number when a (spin) button assigned
to it is pressed. Thanks loads.

Ray Kanner
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Filter Code

Ray,
It can be done, but with the data you supplied, it is near impossible to
write a code.
So come back with a small sample of your table and how the filtered data
should look like.
I am sure that you will get a good response.
Cecil

"Ray Kanner" wrote in message
...
I have a large table with employee ids in asscending order
in the third column. An employee id record is not unique,
so there can be many employee records per employee. Using
a filter, I would like to view all the records pertaining
to one employee at a time. Does anyone have sample code
they could share that would allow the filter to advance to
the next employee id number when a (spin) button assigned
to it is pressed. Thanks loads.

Ray Kanner



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Filter Code

Ray,

The two macros below will set up your sheet to do this. Assumptions: G1 is
currently empty, and your data table starts in A1, and your table is the
only data on the worksheet, and your data is contiguous (no blank rows or
columns). The first macro will set up the spinner, and the second is called
by the spinner to do the filtering of your data set. Once the spinner is set
up, you can drag it to some place convenient.

HTH,
Bernie
MS Excel MVP

Sub SetUpSpinner()
Dim myVRange As Range
Dim myCell As Range

Range("C1", Range("C1").End(xlDown)).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("C65536").End(xlUp)(3), _
Unique:=True
Set myVRange = Range("C65536").End(xlUp).CurrentRegion

ActiveSheet.Spinners.Add(100, 100, 40, 70).Select
With Selection
.Value = 0
.Min = 2
.Max = myVRange.Cells.Count
.SmallChange = 1
.LinkedCell = "$G$1"
.OnAction = "FilterRange"
.Placement = xlFreeFloating
.Visible = True
.Enabled = True
End With

End Sub
Sub FilterRange()
Dim myFRange As Range
Dim myVRange As Range

Set myFRange = Range("C1").CurrentRegion
Set myVRange = Range("C65536").End(xlUp).CurrentRegion

myFRange.AutoFilter Field:=3, Criteria1:=myVRange(Range("G1").Value)
End Sub

"Ray Kanner" wrote in message
...
I have a large table with employee ids in asscending order
in the third column. An employee id record is not unique,
so there can be many employee records per employee. Using
a filter, I would like to view all the records pertaining
to one employee at a time. Does anyone have sample code
they could share that would allow the filter to advance to
the next employee id number when a (spin) button assigned
to it is pressed. Thanks loads.

Ray Kanner



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Filter Code

Hi Ray

Maybe you like this example that copy the records of
every employee in it's own sheet
http://www.rondebruin.nl/copy5.htm

See the last macro


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Ray Kanner" wrote in message ...
I have a large table with employee ids in asscending order
in the third column. An employee id record is not unique,
so there can be many employee records per employee. Using
a filter, I would like to view all the records pertaining
to one employee at a time. Does anyone have sample code
they could share that would allow the filter to advance to
the next employee id number when a (spin) button assigned
to it is pressed. Thanks loads.

Ray Kanner



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Filter Code

Hi Ray,
Doesn't that imply you are filtering on employee rather than employee
ID? Why not just do that from the employee filter dropdown??
regards
Paul

"Ray Kanner" wrote in message ...
I have a large table with employee ids in asscending order
in the third column. An employee id record is not unique,
so there can be many employee records per employee. Using
a filter, I would like to view all the records pertaining
to one employee at a time. Does anyone have sample code
they could share that would allow the filter to advance to
the next employee id number when a (spin) button assigned
to it is pressed. Thanks loads.

Ray Kanner



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter Date Code for macro mulehead Excel Discussion (Misc queries) 2 September 22nd 07 01:13 AM
Code to replace Advanced Filter RobN[_2_] Excel Discussion (Misc queries) 4 June 14th 07 12:31 PM
Filter isn't working with a VBA Code [email protected] Excel Worksheet Functions 8 June 15th 06 01:20 PM
vba filter code Gabriel[_3_] Excel Programming 3 February 22nd 04 06:24 PM
Apply more than one filter in macro/vb code Stepnen Excel Programming 1 February 19th 04 07:49 PM


All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"