View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Critique my filter/copy/visiblecells code...

Hi Howard,

Am Tue, 7 Jun 2016 16:31:24 -0700 (PDT) schrieb L. Howard:

This works pretty good, but seems to me to not be the "proper" use of .VisibleCells.


do you have issues?
For me it works fine and with the cisible cells you are on the save
side.
But Copy method only copies visible cells and so SpecialCells are not
needed:
Sub Many_To_One_Copy_1()

Dim i As Long
Dim MyArr As Variant
Dim lr As Long
Dim rngE As Range, c As Range

MyArr = Array("Sheet2", "Sheet3", "Sheet4", "Sheet5")

Application.ScreenUpdating = False

For i = LBound(MyArr) To UBound(MyArr)

With Sheets(MyArr(i))
.AutoFilterMode = False

lr = .Cells(.Rows.Count, 5).End(xlUp).Row
Set rngE = .Range("$D$1:$E$" & lr)

rngE.AutoFilter Field:=1, Criteria1:="=X"
.Range("$E$2:$E$" & lr).Copy
Sheets("Sheet1").Range("AG" & Rows.Count).End(xlUp)(2).PasteSpecial
Paste:=xlPasteValues

.AutoFilterMode = False

End With
Next 'i

Application.ScreenUpdating = True
End Sub


Regards
Claus B.
--
Windows10
Office 2016