Function FunctionName(str)
Dim resultStr
Dim wordArr
wordArr = Array(Split(str, "_"))
For Each item In wordArr
resultStr = resultStr & UppercaseFirstLetter(item)
Next item
FunctionName = resultStr
End Function 'FunctionName
Consider the above for each loop in VBA. I keep getting the error of Illegal Assignment 'item'
Note: UppercaseFirstLetter is a function that converts the first letter of the given word into uppercase.
I'm new to VBA, any advice is much appreciated!
itemis an object, and your function probably requires astring. Try what @GSerg suggested.StrConv(text, vbProperCase). As for the error, it is not in the shown code, even though it unnecessarily wraps an array returned bySplitinto another array created byArray. Given this code, you should be getting error 13 Type mismatch.