这样?

Sub 随机凑数()
Dim targetValue As Double
Dim currentSum As Double
Dim addend As Integer
Dim resultString As Strin
' 从A1单元格获取目标值
targetValue = Range("A1").Valu
' 初始化当前和与结果字符串
currentSum = 0
resultString = "
' 循环生成随机数直到达到或超过目标值
Do While currentSum < targetValue
' 生成一个介于1到(targetValue - currentSum)之间的随机数
addend = Application.WorksheetFunction.RandBetween(1, targetValue - currentSum)
currentSum = currentSum + addend
If resultString = "" Then
resultString = CStr(addend)
Else
resultString = resultString & "+" & CStr(addend)
End If
Loop
' 将结果字符串写入B1单元格
Cells(1, 2).Value = resultString
' 显示完成消息
MsgBox "加法表达式已生成并写入B1单元格"
End Sub