Reputation: 4008
I'm trying to add this line of code in vba excel for custom function
(days > 0 ? days + ' day' + (days > 1 ? 's' : '') + ' ' : '') + hours+':'+minutes+':'+Math.round(seconds)
This is my first function in vba excel. Its showing the statement in red color. Does excel 2013 support this ?
Upvotes: 0
Views: 208
Reputation: 3634
Something like this should work...
You may need to use CStr(hours) etc depending on how you've Dim'd the variables
If Days > 0 Then
var = Days & Iff(Days > 1, " days ", " day ") & hours & ":" & minutes & ":" & Round(seconds)
End If
EDIT:
To reflect altered question...
Iff(Days > 0, Days & Iff(Days > 1, " days : ", " day : "), "") & hours & ":" & minutes & ":" & Round(seconds)
Upvotes: 3