Hi everyone, I'm having an issue when returning an array to excel with a UDF.
when i launch a shift + F9 to recalculate all the sheet, one of my UDF function is well called and seems to return the good result ( i've set a message box before returning the array and it seems that the array is good), but the result is not display in the cells and so it is the prior result that stay in the cells. Refreshing problem maybe ?
So the other functions in the sheet are recalculated with the wrong datas.
So i have to calculate this function manually and alone cto see the good array in the cells.
Does someone have an idea of why ?
thank you very much. here is the mask of the function :
@xw.func(volatile = True)
@xw.ret(expand='table')
def my_function(parameter1,parameter2):
wb = xw.Book.caller()
sht = wb.sheets['Sheet1']
array= [sht.range((3,i)).value for i in range(1,100)]
array= list(filter(lambda x : x is not None,array))
if parameter1 in array:
row = 5
col = array.index(parameter1 )*5+1
data = sht.range((row,col),(row+200,col+4)).value
data = np.array(list(filter(lambda x : x[0] != None,data)))
new_data = []
for x in data:
if x[0] <= parameter2 and x[3] !=0 and x[4] != 0:
new_data.append(list(x))
elif x[0] > parameter2 and x[1] != 0 and x[2] != 0:
new_data.append(list(x))
msg_box(new_data)
return new_data
else:
return None
Hi everyone, I'm having an issue when returning an array to excel with a UDF.
when i launch a shift + F9 to recalculate all the sheet, one of my UDF function is well called and seems to return the good result ( i've set a message box before returning the array and it seems that the array is good), but the result is not display in the cells and so it is the prior result that stay in the cells. Refreshing problem maybe ?
So the other functions in the sheet are recalculated with the wrong datas.
So i have to calculate this function manually and alone cto see the good array in the cells.
Does someone have an idea of why ?
thank you very much. here is the mask of the function :