'Writing multi-line formula to range using VBA
Desired result in the formula bar:
=IF(True,
1,0)
These return generic 1004 error:
Selection.Formula = "=IF(True," & vbCrLf & "1,0)"
Selection.Formula = "=IF(True," & vbNewLine & "1,0)"
(edited as Chr(10) does actually work, thanks Tim)Selection.Formula = "=IF(True," & CHAR(10) & "1,0)"
Is there any possible workaround to get a new line in the formula bar?
Solution 1:[1]
It appears that the formula bar supports only LF character, but it is possible:
selection.formula = "=IF(True," & vbLf & "1,0)"
As Tim pointed out in a comment above, this also works:
selection.formula = "=IF(True," & Chr(10) & "1,0)"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |