I am new to VBA. Why can't I use following line in a module? But the same line seems to work fine in a sub
ActiveCell.Offset(0, 3).Value = "test"
Function trimto25(ByVal r As String) As String
Dim i As Long
Dim arr As Variant
Dim erg As Variant
arr = Split(r, " ")
erg = arr(0)
For i = 1 To UBound(arr)
If (Len(erg + " " + arr(i)) < 25) Then erg = erg + " " + arr(i) Else:
Exit For
Next i
trimto25 = erg
ActiveCell.Offset(0, 3).Value = "test"
End Function
ERROR-CODE in Excel Sheet: #Value!
This seems to work fine: (But why does it work in the sub and not the function)
Sub s()
ActiveCell.Offset(0, 3).Value = "test"
End Sub