Excel:从特定单元格返回单元格值

时间:2021-09-27 22:15:39

I need to take the cell value, which cell row position is variable by another cell value.

我需要获取单元格值,单元格行位置可以通过另一个单元格值变化。

Ex:

B2 = 10

B2 = 10

I need to take the value of M10

我需要取M10的值

If it was B2=6 I would have needed the value of M6.

如果它是B2 = 6,我将需要M6的值。

Thanks!

2 个解决方案

#1


2  

I think you are searching for "INDIRECT" in your example :

我想你在你的例子中搜索“间接”:

B2 = INDIRECT("M" & 10, TRUE) ' Will return the value of M10.

True is for "A1" ref, FALSE for "L1C1"

对于“A1”ref为真,对于“L1C1”为FALSE

Let's say, the line you are aiming is indicated in A4

比方说,你瞄准的线用A4表示

if A4 = 6

如果A4 = 6

B2 = INDIRECT("M" & A4, TRUE) ' Will return the value of M6.

#2


1  

Dim NewValue as string
NewValue = range("B2").value
Range("M & NewValue") 

This would give you m + whatever is is B2 cell

这会给你m +什么是B2细胞

Sorry This is VBA is you know that.

对不起这是VBA你知道吗。

#1


2  

I think you are searching for "INDIRECT" in your example :

我想你在你的例子中搜索“间接”:

B2 = INDIRECT("M" & 10, TRUE) ' Will return the value of M10.

True is for "A1" ref, FALSE for "L1C1"

对于“A1”ref为真,对于“L1C1”为FALSE

Let's say, the line you are aiming is indicated in A4

比方说,你瞄准的线用A4表示

if A4 = 6

如果A4 = 6

B2 = INDIRECT("M" & A4, TRUE) ' Will return the value of M6.

#2


1  

Dim NewValue as string
NewValue = range("B2").value
Range("M & NewValue") 

This would give you m + whatever is is B2 cell

这会给你m +什么是B2细胞

Sorry This is VBA is you know that.

对不起这是VBA你知道吗。