我对这个疯狂了。我尝试过滤Sheet" Detail Aging(2)"上的第一列,但过滤器值随时间变化,我需要在将来不修改宏。
我想过使用范围从不同工作簿中的工作表中提取过滤器值,但我无法引用该工作簿中的工作表。我得到"下标超出范围"。
以下是我正在使用的代码段。当具有范围的工作表位于同一工作簿上时,它可以正常工作。
Dim vCrit As Variant
Dim wsO As Worksheet
Dim wsL As Worksheet
Dim rngCrit As Range
Dim rngOrders As Range
Set wsO = Worksheets("Detail Aging (2)")
Set wsL = Worksheets("C:\Users\lm733600\Desktop\Fabrizio\[Collectible Blank.xlsm]Collectors")
Set rngOrders = wsO.Range("$A$1").CurrentRegion
Set rngCrit = wsL.Range("ColRange")
非常感谢任何建议!
答案 0 :(得分:3)
使用工作簿对象
Dim vCrit As Variant
Dim wsO As Worksheet
Dim wsL As Worksheet
Dim rngCrit As Range
Dim rngOrders As Range
Set wsO = Worksheets("Detail Aging (2)")
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:="C:\Users\lm733600\Desktop\Fabrizio\Collectible Blank.xlsm", ReadOnly:=True)
set wsL = wb.Sheets("Sheet1")
Set rngOrders = wsO.Range("$A$1").CurrentRegion
Set rngCrit = wsL.Range("ColRange")