vba 使用excel单元格公式获取单元格地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15081254/
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
Get the cell address using excel cell formula
提问by user1884324
My date range starting point can vary at any column, but the row is always fixed at row 2.
For example, my current date range covers from A2:AB2
col A | col B | col C | ...
blank | 1-Jan | 2-Jan | ...
我的日期范围起点可以在任何列变化,但行始终固定在第 2 行。例如,我当前的日期范围涵盖 A2:AB2
col A | 列 B | 上校 | ...
空白 | 1-1 月 | 1 月 2 日 | ...
I need to achieve the following: If I enter a date(eg. 2-Jan) at cell A5, cell B5 will display the cell address ($C$2) which contains the date (2-Jan).
我需要实现以下目标:如果我在单元格 A5 输入日期(例如 2-Jan),单元格 B5 将显示包含日期(2-Jan)的单元格地址($C$2)。
How do I achieve this?
我如何实现这一目标?
回答by chuff
The following formula in cell B5 should do the job:
单元格 B5 中的以下公式应该可以完成这项工作:
=IFERROR(ADDRESS(2,MATCH(A5,$A2:$AB2,0)),"")
Note that row 2 is hard-coded in the formula by the 2 in the address function.
请注意,第 2 行在公式中由地址函数中的 2 硬编码。