Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Filter copy incl more than it should

Hi all
My code below should filter data for criteria and copy data to another
worksheet

However, incl at least 1 row that should not be included
Will incl header row as well depending on rnage I specify

What am I doing wrong here?
Thanks
-goss

Sub pus_Filters()
Dim wbBook As Workbook
Dim wsData As Worksheet
Dim wsDCB As Worksheet
Dim wsSetups As Worksheet
Dim i As Integer
Dim Rng As Range
Dim rngCopyTo As Range
Dim rngCopyFrom As Range
Dim myArray(3) As String

'//Environment
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

'//Objects
Set wbBook = ThisWorkbook
With wbBook
Set wsData = .Worksheets("Data")
Set wsSetups = .Worksheets("Setups")
Set wsDCB = .Worksheets("DCB")
End With
i = 1

'//Processes
'//Load Array
Do While i <= 3
With wsSetups
myArray(i) = .Cells((i + 1), 8)
End With
i = i + 1
Loop


'//Filter and copy
i = 3
Do While i = 1
With wsData
Set Rng = .Range("A2:L" & Get_Rows)
End With

With Rng
.AutoFilter Field:=12, Criteria1:=myArray(i)
End With

With wsData
Set rngCopyFrom = .Range("A1:L" &
Get_Rows).SpecialCells(xlCellTypeVisible)
End With

With wsDCB
Set rngCopyTo =
..Range("A65536").End(xlUp).Offset(1, 0)
End With

rngCopyFrom.Copy rngCopyTo

With Rng
.AutoFilter
End With

i = i - 1
Loop

'//Cleanup
Set wbBook = Nothing
Set wsData = Nothing
Set wsDCB = Nothing
Set Rng = Nothing
Set rngCopyTo = Nothing
Set rgnCopyFrom = Nothing

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True


End Sub

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
Copy only visible cells after filter is applied/ sum after filter MAM Excel Worksheet Functions 0 April 9th 08 04:09 AM
if search formula incl date range Laury Excel Worksheet Functions 4 October 3rd 07 01:10 AM
Sum on 2 criteria, incl #REF! Ray Excel Discussion (Misc queries) 5 January 10th 07 03:20 PM
convert a value to a text incl apostrophe within the cell Jakob Excel Worksheet Functions 2 October 16th 06 06:13 PM
Delete all files within a folder (incl subfolders) Steph[_3_] Excel Programming 1 September 30th 04 09:59 PM


All times are GMT +1. The time now is 05:34 AM.

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"