Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Copying data based on filter criteria

I have a workbook with a series of worksheets (more than 25). I need to do
the following:
For each worksheet 2 through 'n'
Sort/Filter on column M "Impact" for Impact = Global
Copy all data (about 15 columns) for each row with Impact = Global and paste
rows into Worksheet1 starting with Cell B24 down

So, for the next worksheet (i.e. Worksheet 3), the paste function should
remember the last row written and begin pasting from the next row.

Please let me know how to do this. I have limited knowledge of Macros /
Pivot Tables and Programming using VB


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 897
Default Copying data based on filter criteria

Hello,

This will do most of what you want. For some reason I can't get the
code to stop copying the headers, after the first time. Also, you'll
have to adjust the code to start pasting from row 24, but it's a
start.

Sub autofiltervisibleandcopytonewwkbk()
' This will add a new worksheet to your workbook, go through each
worksheet, filter on column M for word "Global", copy filtered rows to
the new workbook
Dim rng As Excel.Range
Dim NewSht As Worksheet
Dim i As Integer

Application.ScreenUpdating = False

Set NewSht = Sheets.Add(After:=Sheets(Sheets.count))
Sheets(1).Activate
sheetnum = 1
For i = 1 To Worksheets.count - 1
Sheets(i).Activate
ActiveSheet.UsedRange
Set rng = ActiveSheet.UsedRange.Rows
With rng
.AutoFilter Field:=13, Criteria1:="=Global"
End With

With ActiveSheet.AutoFilter.Range
On Error Resume Next
If sheetnum 1 Then
Set rng = .Offset(0, 0).Resize(.Rows.count - 1, _
.Columns.count).SpecialCells(xlCellTypeVisible)
Else
Set rng = .Offset(0,
0).Resize(.Rows.count, .Columns.count).SpecialCells(xlCellTypeVisible)
End If
On Error GoTo 0
End With
If sheetnum 1 Then

rng.Copy NewSht.Range("A65536").End(xlUp).Offset(1, 0)
Else
rng.Copy NewSht.Range("A65536").End(xlUp)
End If
sheetnum = sheetnum + 1
Next i

Application.ScreenUpdating = True
End Sub


On Jan 10, 3:22*pm, no_rhythm
wrote:
I have a workbook with a series of worksheets (more than 25). I need to do
the following:
For each worksheet 2 through 'n'
Sort/Filter on column M "Impact" for Impact = Global
Copy all data (about 15 columns) for each row with Impact = Global and paste
rows into Worksheet1 starting with Cell B24 down

So, for the next worksheet (i.e. Worksheet 3), the paste function should
remember the last row written and begin pasting from the next row.

Please let me know how to do this. I have limited knowledge of Macros /
Pivot Tables and Programming using VB


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
Run Filter criteria based on data in range Mitch4 Excel Discussion (Misc queries) 0 October 17th 07 04:15 PM
data filter criteria based on cell references? scshop Excel Worksheet Functions 1 June 22nd 07 03:16 AM
Copying data from one worksheet to another based on criteria Caatt Excel Discussion (Misc queries) 1 June 15th 06 10:19 AM
copying cells based on criteria tdro Excel Worksheet Functions 0 June 15th 05 02:17 PM
Copying whole rows based upon one criteria kirbster1973 Excel Discussion (Misc queries) 2 May 26th 05 10:00 PM


All times are GMT +1. The time now is 07:40 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"