Serving the Quantitative Finance Community

 
User avatar
dkkchan
Topic Author
Posts: 1
Joined: November 10th, 2003, 1:54 pm

bloomberg =blph that returns a matrix without Ctrl+shift+Enter

March 22nd, 2005, 3:25 pm

I was having a hard time to get rid of the necessity of pressing Ctrl+Shift+Enter after entering a function that return a matrix/array. My customised function will return x rows and y columns. Everytime is different. Since x and y are unknow to me when that time I initialise the function, I have to pre-select the size of the array in the spreadsheet by trial & error. The problem is particular difficult to me since any subroutine within my customised function that targets to write to the other cells that is not the cell (original) one enters when the function is initialised, would be ignored.Is there any method (subroutine/function) to expand the results (matrix/array) fully like bloomberg's =blph function by displaying the only rows up to x and columns up to y immediately after keying "=myfnc(,,,)" without pre-select cells and keying {Ctrl+Shift+Enter}.thx a lotdan
 
User avatar
RedAlert
Posts: 2
Joined: April 11th, 2002, 10:54 am

bloomberg =blph that returns a matrix without Ctrl+shift+Enter

March 23rd, 2005, 9:50 pm

Dan,If I've understood your question correctly, here's a brief outline of one way you can do this:Option ExplicitSub test()Dim bbfunctionoutput As VariantDim i As Long, j As Longbbfunctionoutput=application.run("blph",.....) ' fll this in appropriatelyx = UBound(bbfunctionoutput, 1)y = UBound(bbfunctionoutput, 2)For i = 1 To x For j = 1 To y Range("a1").Cells(i, j).Value = bbfunctionoutput(i, j) Next jNext iEnd SubRegards,F.
 
User avatar
dkkchan
Topic Author
Posts: 1
Joined: November 10th, 2003, 1:54 pm

bloomberg =blph that returns a matrix without Ctrl+shift+Enter

March 24th, 2005, 5:05 am

Thx for the idea.Let me talk about it more. Actually, I need a function that will expand a return matrix/array automatically without preselecting cells beforehand. I can write functions but if the function returns a matrix/array of values, I may have to preselect cells in the spreadsheet to show all the values from the matrix/array. I couldn't find any trick that can get around the necessity of preselecting cells. Regardsdan