Description: JOIN() should use the second parameter as a separator rather than as an element terminator. Currently, in Calc macros, the JOIN function returns the array as separator-joined string but with the separator appended. This is a BAD thing. Steps to Reproduce: 1. Create a macro (in this case called "goofyJoin" and enter the following code public function goofyJoin(byval R as range) as string if not isarray(R) then msgbox "no range selected" exit function end if dim result(ubound(R)) as string dim c as integer c = 0 dim v as variant for each v in R result(c) = v c=c+1 next dim out as string out = join(result,",") goofyJoin = out end function 2. In a spreadsheet, create a range of numbers. 3. In a nearby cell enter the formula =goofyJoin() and give it the previously defined range and the separator (e.g. ",") Actual Results: The range is joined appropriately, but the separator is also appended. Expected Results: The range joined with the separator used as a "separator" Reproducible: Always User Profile Reset: No Additional Info: Currently I handle this with if right(out,1) = "," then out = mid(out,1,len(out)-1) end if The issue came up when using Calc to build JSON
Created attachment 148109 [details] screenshot IMHO it should work if you use: > dim result(ubound(R)-1) please have a look at the attachment - ubound is 4 but array start with 0