Excel - 公式或宏,以基于链接到另一个单元格的另一个单元格填充单元格 [英] Excel - Formula or Macro to fill a cell based on another cell that links to yet another cell

查看:199
本文介绍了Excel - 公式或宏,以基于链接到另一个单元格的另一个单元格填充单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在Excel中创建一个基于另外两个单元格中的值的单元格。我需要单元格X和Y以基于单元格的数据L和#,像这样....

  XYL 1 2 3 4 5 6 

A 6 1 1 6; 1 6; 1 7; 1 7; 2 7; 2 8; 1
B 7 2 4 6; 1 6; 1 7; 1 7; 2 7; 2 8; 1

因此,行A具有根据数字列中的值填充列X和Y。需要的具体号码是列L中填写的内容。



我不知道最佳的方法来说明这个问题。如果我的例子没有意义,我可以尝试澄清或提供更多的例子。
我不知道如果这可以用花哨的公式或一个VBA宏或两个。我是一个excel noob。

解决方案

如果我已经正确地理解了你的问题,你可以用 / 索引搜索



在我的示例图像中,用户在列 D 中输入其值,然后列 B C 使用formulea

  = LEFT(INDEX($ F2:$ K2,1,$ D2),(SEARCH( ;,INDEX($ F2:$ K2,1,$ D2)) -  1)) 

= RIGHT(INDEX($ F2:$ K2,1,$ D2),(SEARCH(;,INDEX($ F2:$ K2,1,$ D2)) - 1))

分别







这里,索引函数返回正确的要查看的列(即用户选择的值,搜索函数查找分号的位置,并且 / right 函数返回分号两边的值。


In Excel, I am trying to make a cell based of the values contained in two other cells.

I need Cells X and Y to have data based on Cells L and #, like so....

     X     Y      L       1     2     3     4     5     6

A    6     1      1      6;1   6;1   7;1   7;2   7;2   8;1
B    7     2      4      6;1   6;1   7;1   7;2   7;2   8;1

So row A, has columns X and Y filled based of the values in the number columns. The specific number needed is what is filled in in column L.

I am not sure the best way to phrase this question. If my example doesn't make sense, I can try to clarify or provide more examples. I have no idea if this can be done with fancy formulas or with a VBA macro or two. I am an excel noob.

解决方案

If I've understood your question correctly you can do this with a combination of Left/Right, Index and search.

In my example images, the user inputs their value in column D, and then columns B and C use the formulea

=LEFT(INDEX($F2:$K2,1,$D2),(SEARCH(";",INDEX($F2:$K2,1,$D2))-1))

=RIGHT(INDEX($F2:$K2,1,$D2),(SEARCH(";",INDEX($F2:$K2,1,$D2))-1))

respectively

Here, the Index function returns the correct column to look at (i.e. the value chosen by the user, the Search function finds the position of the semi-colon, and the left/right functions return the values either side of the semi-colon.

这篇关于Excel - 公式或宏,以基于链接到另一个单元格的另一个单元格填充单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆