沒有經驗的 Stackoverflow 用戶,如果需要,請隨時將我指向其他論壇或子論壇。
我創建了以下 VBA(然后還在線查看了其他代碼示例,它們似乎都遵循相同的邏輯)。我在除錯視窗中進行測驗并準確地看到我期望的結果(多行字串)。但是,當我在作業表單元格中鍵入公式時,出現 #Value 錯誤。
- 該函式拼寫正確(我實際上是在 Excel 中從公式自動完成中選擇的)
- Excel x64 v2108,在 Win10 x64 上本地安裝
任何想法為什么這不會用公式填充回單元格?
Function ConcatCells()
'just to be safe, clear the string
ConcatCells = ""
'Loop and add each cell text with a line break
For Each cell In Selection
ConcatCells = ConcatCells & Chr(13) & cell.Text
Next
'remove the leading line break
ConcatCells = Right(ConcatCells, Len(ConcatCells) - 1)
'is the string actually being created correctly? Yes
Debug.Print ConcatCells
End Function
uj5u.com熱心網友回復:
將Selection As Range作為引數添加到您的函式中: Function ConcatCells(Selection As Range)
在此之后,您的函式將回傳如下值: OneTwoThreeFourFive
當您復制此單元格并粘貼為值時,
在點擊F2and 后Enter,你會看到這樣的視圖:

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/353774.html
下一篇:多個單元格自動過濾
