Excel获取命名动态范围的范围(OFFSET)

时间:2016-09-07 01:56:43

标签: excel-vba dynamic reference range cell

嗨我在Sheet1上有一个下拉单元格的数据验证,List是一个命名的动态范围,其公式为:  = OFFSET(Sheet 2中$ $Ĵ3,0,0,COUNTA(Sheet 2中$ Y:!$ j)-2,1)

工作正常。

但是现在我想获得Excel单元格参考;在我的例子中,范围是sheet2!$ j $ 3:$ j $ 30。我需要将该字符串放入Range引用

我通过解析完成了这项工作,但减慢了我的电子表格

2 个答案:

答案 0 :(得分:1)

您提出的问题的VBA解决方案可能是:

$ ghc -rtsopts -prof -fprof-auto -threaded testNaN.hs && ./testNaN +RTS -xc -N2
[1 of 1] Compiling Main             ( testNaN.hs, testNaN.o )
Linking testNaN ...
testNaN: lost signal due to full pipe: 8

testNaN: lost signal due to full pipe: 8

testNaN: lost signal due to full pipe: 8

... repeat many many times, very very fast

但也许你真正想做的是:

Dim x as String
With Worksheets("Sheet2")
    x = "'" & .Name & "'!" & .Range("J3", .Range("J3").Offset(Application.WorksheetFunction.CountA(.Columns("J")) - 2, 0)).Address
End With
'The value of variable x is now the address you asked for

答案 1 :(得分:1)

你不需要做任何特别的事情。公式将返回有效范围。

enter image description here