引用 Excel VBA 中的活动单元格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26037976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:39:15  来源:igfitidea点击:

Reference to the Active Cell in Excel VBA

excelvbacell

提问by user4079167

How do I reference to the Active Cell in a macro?

如何在宏中引用活动单元格?

For example if I want to open a document with the name of the Active Cells value.

例如,如果我想打开一个名为 Active Cells 值的文档。

Workbooks.Open Filename:= _
"F:\AKTIVITETER14\TKC14066_XXX_HELMASKIN-BULLERDATABAS_BULLER\LJUDRAPPORTER\??????.xls"

回答by JoriO

ActiveCell does the trick :) Like this:

ActiveCell 可以解决这个问题 :) 像这样:

Workbooks.Open (ActiveCell.Value)

回答by Goos van den Bekerom

To Use your code do this:

要使用您的代码,请执行以下操作:

Workbooks.Open Filename:= ActiveCell.Value

回答by Gary's Student

Make the string:

制作字符串:

Sub luxation()
    Dim txt As String
    txt = ActiveCell.Value
    Workbooks.Open Filename:= _
        "F:\AKTIVITETER14\TKC14066_XXX_HELMASKIN-BULLERDATABAS_BULLER\LJUDRAPPORTER\" & txt & ".xls"
End Sub