I asked this question a bit ago, but asked it开发者_Python百科 incorrectly, and wasn't able to receive the best answer.
I have a fairly simple syntax question:
I'm trying to copy and paste n rows from one excel file to another. In addition, I'd like to store the total FILTERED copied rows into a variable. Can someone help me accomplish this?
For example:
'1) Activate CSV file, Apply Filter to Column B (Page Title) & uncheck "blanks" ("<>") filter
Windows("Test_Origin.xlsm").Activate
ActiveSheet.Range("$A$1:$J$206").AutoFilter Field:=2, Criteria1:="<>"
'2) Copy Filtered Lines with data (Excluding Row 1)
Range("B2:F189").Select
Selection.Copy
copiedRowTotal = Selection.Rows.Count <-- This doesn't give me the FILTERED rows
Thanks
dim i as long
i = Application.WorksheetFunction.Subtotal(2,worksheets("Sheet").Range("B2:F189"))
Gave you the description here Getting a total copied set of rows in VBA and storing it in a variable
Try:
copiedRowTotal = Range("B2:B189").SpecialCells(xlCellTypeVisible).Count
精彩评论