excel vba - VBA - Selection.Formula does not return everything -


say have long formula in 1 of cells in excel:

=if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 01", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 02", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 03", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 04", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 05", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 06", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 07", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 08", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 09", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 10", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 11", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 12", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 13", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 14","no" ))))))))))))))

now when call following vba sub

private sub get_formula()     msgbox selection.formula end sub 

then don't receive full formula,

=if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 01", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 02", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 03", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 04", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 05", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 06", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 07", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 08", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 09", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 10", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 11", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 12", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z 13", if(sum(d3:d6)>1,"a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v

how can obtain full formula?

the "prompt" parameter of msgbox function has maximum length approximately 1024 characters, depending on width of characters used. (see https://msdn.microsoft.com/en-us/library/office/gg251821(v=office.15).aspx)

you can obtain entire formula printing in visual basic immediate window code:

sub get_formula()     rem opens immediate window , clears     sendkeys "^g^a{del}": stop      activecell         debug.print vblf; vblf; string(131, "*")         debug.print "formula in wbk\wsh\cell: "; .parent.parent.name; " \ "; .parent.name; " \ "; .address(0, 0)         debug.print activecell.formula         debug.print vblf; string(131, "*"); vblf     end     sendkeys "^g^{home}" ': stop end sub 

additionally, see inconsistencies in formula guess bogus formula used explain problem msgbox function. long formulas difficult read, may suggest use alt+enter keys combined start new line in same cell breaking formula in several lines (see picture below)

enter image description here


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -