开发者

Getting a total copied set of rows in VBA and storing it in a variable

开发者 https://www.devze.com 2023-04-05 02:32 出处:网络
I asked this question a bit ago, but asked it开发者_Python百科 incorrectly, and wasn\'t able to receive the best answer.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消