View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_6_] GS[_6_] is offline
external usenet poster
 
Posts: 1,182
Default Critique my filter/copy/visiblecells code...

Just another way, but uses less code...

Sub Many_To_One_Copy_2()
Dim rng As Range, lLastRow&, v
Const sShtsList$ = "Sheet2,Sheet3,Sheet4,Sheet5"

Application.ScreenUpdating = False
For Each v In Split(sShtsList, ",")
With Sheets(v)
.AutoFilterMode = False
lLastRow = .Cells(.Rows.Count, 5).End(xlUp).Row
Set rng = .Range("$D$1:$E$" & lLastRow)

rng.AutoFilter Field:=1, Criteria1:="=X"
.Range("$E$2:$E$" &
lLastRow).SpecialCells(xlCellTypeVisible).Copy
Sheets("Sheet1").Range("AG" &
Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues
rng.AutoFilter
End With 'Sheets(v)
Next 'v
Application.ScreenUpdating = True
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus