简体   繁体   English

如何在Excel公式中显示已解析的名称

[英]How to Display resolved Names in Excel Formulas

Is there an easy way for me to turn the following, if only for a second, into real SQL?: 是否有一种简单的方法可以将以下内容(如果仅一秒钟)转换为真实的SQL?

=IFERROR(eagle("SELECT SUM("&selectedmonth&")/1000, ("& ytdformula & ")/1000 AS YTD, sum(Budget)*"&sMonthIndex&"/12000
             FROM ["&environment&"].[dbo].[SD_"&selectedyear&"_flat" & IF(selectedCurrency="USD","","_EUR") &"]
             WHERE 1=1
             "&IF(selectedDepartment="All",""," AND department = '"&selectedDepartment&"'")&" 
             "&IF(selectedproduct="All",""," AND product = '"&selectedproduct&"'")&"      
             "&IF(AND(getMacro=FALSE,getRatesNSU=FALSE),
               IF(selecteddivision="All",""," AND division='"&selecteddivision&"'"),
               IF(getMacro=TRUE," AND (division = 'Commodities' OR division = 'FX Products' OR division = 'Rate Products')"," AND (division = 'Rate Products' OR product = 'IB Non-Strategic Unit')"))&"
             "&IF(exclSMG=FALSE,""," AND Division <> 'Systematic Market Making'")&"
             "&IF(selectedsubdivision="All",""," AND subdivision = '"&selectedsubdivision&"'")&"
             "&IF(selectedcluster="All",""," AND cluster = '"&selectedcluster&"'")&"    
             "&IF(selectedregion="All",""," AND region = '"&selectedregion&"'")&"
             "&IF(selectedBiz="All",""," AND business_unit IN "&selectedBiz),connectionString),0)

Put the word stop in front of this line of code then paste the following into the VBA Immediate window with a question mark in front of it. 将单词stop放在此代码行的前面,然后将以下内容粘贴到VBA Instant窗口中,并在其前面带有问号。

?"SELECT SUM("&selectedmonth&")/1000, ("& ytdformula & ")/1000 AS YTD, sum(Budget)*"&sMonthIndex&"/12000
         FROM ["&environment&"].[dbo].[SD_"&selectedyear&"_flat" & IF(selectedCurrency="USD","","_EUR") &"]
         WHERE 1=1
         "&IF(selectedDepartment="All",""," AND department = '"&selectedDepartment&"'")&" 
         "&IF(selectedproduct="All",""," AND product = '"&selectedproduct&"'")&"      
         "&IF(AND(getMacro=FALSE,getRatesNSU=FALSE),
           IF(selecteddivision="All",""," AND division='"&selecteddivision&"'"),
           IF(getMacro=TRUE," AND (division = 'Commodities' OR division = 'FX Products' OR division = 'Rate Products')"," AND (division = 'Rate Products' OR product = 'IB Non-Strategic Unit')"))&"
         "&IF(exclSMG=FALSE,""," AND Division <> 'Systematic Market Making'")&"
         "&IF(selectedsubdivision="All",""," AND subdivision = '"&selectedsubdivision&"'")&"
         "&IF(selectedcluster="All",""," AND cluster = '"&selectedcluster&"'")&"    
         "&IF(selectedregion="All",""," AND region = '"&selectedregion&"'")&"
         "&IF(selectedBiz="All",""," AND business_unit IN "&selectedBiz),connectionString),0)

The Immediate window will concatenate all the variables and literals into the SQL String that it is attempting to execute. Instant窗口会将所有变量和文字连接到它试图执行的SQL String中。

IF there is errors in the SQL, you should be able to copy the SQL into the QBE editor to get the error message the compiler cannot reconcile. 如果SQL中存在错误,则应该能够将SQL复制到QBE编辑器中,以获取编译器无法协调的错误消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM