如何在Excel中为公式生成字符串?

时间:2017-02-19 05:24:45

标签: excel formula

我使用CONCATENATE函数构建了这样的公式:

=CONCATENATE("=SUM('D:\Tour\", TEXT(A2,"yyy"), "\", TEXT(A2,"mmmm"), "\", TEXT(A2,"mmm"), " ", TEXT(A2,"d"), "\[", B2, ".xlsx]Sheet1'!E:E)")

并返回如下输出:

  

= SUM(' D:\ Tour \ 2017 \ February \ Feb 1 [11043.xlsx] Sheet1'!E:E)

A列包含日期,B列包含文件名。

此时,我将公式复制到记事本中,然后粘贴回Excel。我有什么方法可以直接使用这个公式吗?

(我试过间接公式,但它没有用。)

1 个答案:

答案 0 :(得分:0)

根据this question的答案,您可以编写以下VBA函数:

#!/usr/bin/env bash
set -x

term_handler() {
  echo "Stopping the server process with PID $PID"
  erl -noshell -name "term@127.0.0.1" -eval "rpc:call('app@127.0.0.1', init, stop, [])" -s init stop
  echo "Stopped"
}

trap 'term_handler' TERM INT

elixir --name app@127.0.0.1 -S mix run --no-halt &
PID=$!

echo "Started the server process with PID $PID"
wait $PID

# remove the trap if the first signal received or 'mix run' stopped for some reason
trap - TERM INT

# return the exit status of the 'mix run'
wait $PID
EXIT_STATUS=$?

exit $EXIT_STATUS

并从Excel调用它:

Function EV(s As String) As Variant
    EV = Evaluate(s)
End Function

=EV("=A1+B1")

有一个second answer to that question不涉及VBA,但我无法让它工作。