如果在Microsoft Excel excel中{2}数组中存在值,则需要提取列标题

时间:2018-02-22 17:37:20

标签: excel excel-formula

我有这个2d数组表(图像附表1)。

table 1

我想为所有用" x"标记的标签提取列名。例如:对于标签1,我想要返回值A和G.同样,对于标签2,应返回A,C和F.我怎么能在excel中做到这一点?

感谢您的期待。

2 个答案:

答案 0 :(得分:0)

I2 中输入:

=MID(IF(B2="x","," & $B$1,"") & IF(C2="x","," & $C$1,"") & IF(D2="x","," & $D$1,"") & IF(E2="x","," & $E$1,"") & IF(F2="x","," & $F$1,"") & IF(G2="x","," & $G$1,"") &  IF(H2="x","," & $H$1,""),2,99)

并向下复制:

enter image description here

答案 1 :(得分:0)

def ispangram(s):
  stringy = ''
  flag = True
  validLetters = "abcdefghijklmnopqrstuvwxyz"

  #transform the given string in simple string with no symbols only letters
  for char in s.lower():
    if(char in validLetters):
      stringy += char

  #check if all the letters of the alphabet exist on the string
  for char in validLetters:
    if(char in stringy):
      pass
    else:
      flag = False
      break

  return flag

if(ispangram("We promptly judged antique ivory buckles for the next prize")):
  print("It's PANGRAM!")
else:
  print("It's not Pangram :(")

然后,您可以将其向下拖动并跨越所有其他行。假设您的数据在A1中开始,这就是它的样子:

.