janthonyn
asked on
VBA function saved in personal.xls project returns #NAME? error
I added code for a worksheet function and saved it in a module in the PERSONAL.xls VB project. When I use this function in a worksheet formula, I'm supposed to be able to reference the values in a range of cells and return a concatenated text with the repeated separators entered into the second parameter of the function.
Function Join(RangeToJoin As Range, BetweenEach)
Join = " "
For Each cell In RangeToJoin
Join = Join & cell.Value & BetweenEach
Next cell
'Get rid of the final Between
If Len(Join) > 0 Then
Join = Left(Join, Len(Join) - Len(BetweenEach))
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, JOIN() is the name of an intrinsic VBA function, partnered with the SPLIT() function. You should avoid naming functions and variables that are the same as your (VB) language items.
ASKER
I added the variable definition which was missing in the first iteration of my code