如何在VBA中将空格作为输出的一部分?
我目前有以下代码:
Select :P36_PRODUCT_LISTING,
LISTAGG(b.product_name, ', ') WITHIN GROUP (ORDER BY b.product_name) OVER (PARTITION BY B.SALES_ORDER_NUMBER) AS products,
...
from ORDER o join
PRODUCTS_BOUGHT B
on p.SALES_ORDER_NUMBER = B.SALES_ORDER_NUMBER
where (:P36_PRODUCT_LISTING = 'All' or
o.SALES_ORDER_NUMBER IN (SELECT SALES_ORDER_NUMBER
from PRODUCTS_BOUGHT
where PRODUCT_NAME = :P36_PRODUCT_LISTING
)
);
我想生成如下输出:
CellData = "AAAAA" & Space & "BBBBB"
但是使用上面的代码,我只能生成:
"AAAAA" "BBBBB"
答案 0 :(得分:2)
好" "
是一个空间,所以
?"AAAAA" & " " & "BBBBB"
AAAAA BBBBB
或者如果你想要引号
?"""AAAAA""" & " " & """BBBBB""
"AAAAA" "BBBBB"
当然是:
? """AAAAA"" ""BBBBB""
"AAAAA" "BBBBB"
Space
如果您拥有的函数名称无效,您可以:
"AAAAA" & Space$(1) & "BBBBB"
单个空间。
答案 1 :(得分:2)
其中任何一个都可行:
Sub PrintSpace()
Debug.Print "a" & Chr(32) & "a"
Debug.Print "a" & " " & "a"
End Sub