Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
cdb cdb is offline
external usenet poster
 
Posts: 62
Default Selecting using autofilter

I've got a spreadsheet and on one of the sheets within it there is some data
I want to move about depending on the result of an autofilter. Basically I
have a list of applicant information and the last column is a date filter
(that shows the month and year) e.g:

Name Address Age Date Filter
Joe Here 21 72004
Fred There 37 72004
Anne Everywhere 26 82004

The other sheets within the spreadsheet are copies of the data in the first
sheet seperated by month. The code I am after is for the filter to select the
date (e.g. 72004) and then place that into the relevant sheet (e.g. Jul 04).
I have managed to get the code to do this until there is no data for one of
the months e.g. using the data aboce if I was to select 92004. When I do this
it just selects all the data and pastes it into the sheet.

Is there anyone who can help me?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting using autofilter

Sub Macro1()
Dim sNum As String, sSh As String
Dim rng As Range, i As Long, rng1 As Range
For i = 1 To 12
sNum = CLng(i & "2004")
sSh = Format(DateSerial(2004, i, 1), "mmm yy")
With ActiveSheet.AutoFilter.Range
.AutoFilter Field:=4, Criteria1:=sNum
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1)
End With
Set rng1 = Nothing
On Error Resume Next
Set rng1 = rng.Columns(1).SpecialCells(xlVisible)
On Error GoTo 0
If Not rng1 Is Nothing Then
rng.Copy Destination:=Worksheets(sSh) _
.Cells(Rows.Count, 1).End(xlUp)(2)
End If
Next i

End Sub

--
Regards,
Tom Ogilvy



"cdb" wrote in message
...
I've got a spreadsheet and on one of the sheets within it there is some

data
I want to move about depending on the result of an autofilter. Basically I
have a list of applicant information and the last column is a date filter
(that shows the month and year) e.g:

Name Address Age Date Filter
Joe Here 21 72004
Fred There 37 72004
Anne Everywhere 26 82004

The other sheets within the spreadsheet are copies of the data in the

first
sheet seperated by month. The code I am after is for the filter to select

the
date (e.g. 72004) and then place that into the relevant sheet (e.g. Jul

04).
I have managed to get the code to do this until there is no data for one

of
the months e.g. using the data aboce if I was to select 92004. When I do

this
it just selects all the data and pastes it into the sheet.

Is there anyone who can help me?



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
HELP: Selecting Non-Visible (Hidden) Cells when AutoFilter is Appl west8100 Excel Worksheet Functions 2 February 11th 09 09:20 PM
HELP: Selecting Non-Visible (Hidden) Cells with AutoFilter Applied west8100 Excel Discussion (Misc queries) 0 February 10th 09 09:28 PM
HELP: Selecting Non-Visible (Hidden) Cells with AutoFilter Applied west8100 Excel Discussion (Misc queries) 0 February 10th 09 09:28 PM
Selecting Filtered records only when AutoFilter is on Owen Vickers Excel Programming 4 February 21st 04 02:20 AM
Selecting Range After AutoFilter Randal W. Hozeski Excel Programming 4 December 28th 03 03:12 PM


All times are GMT +1. The time now is 04:55 PM.

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

About Us

"It's about Microsoft Excel"