{"id":201,"date":"2013-02-05T15:31:28","date_gmt":"2013-02-05T20:31:28","guid":{"rendered":"https:\/\/jeremystein.com\/brain\/?p=201"},"modified":"2013-02-05T15:44:03","modified_gmt":"2013-02-05T20:44:03","slug":"excel-vba-function-displays-value-on-open-but-works-when-recalculated","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/excel-vba-function-displays-value-on-open-but-works-when-recalculated\/","title":{"rendered":"Excel VBA function displays &#8220;#value!&#8221; on open, but works when recalculated"},"content":{"rendered":"<p>I had an Excel UDF that I was using with Excel 2010 in a xlsm file.  The function worked fine, but after I saved and re-opened the file, the values would switch from their calculated value to the &#8220;#VALUE!&#8221; error message.  If I hit F2 on any of the cells and hit enter to recalculate, the correct value for all the cells would be displayed.<\/p>\n<p>It turned out that this was because the UDF had a range parameter that covered cells which used calculations from external data.  When the external data was refreshed (as I had configured it to do on Open), the UDF iterated over the cells in the range and accessed their Text property.  When I changed from Text to Value, it worked.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had an Excel UDF that I was using with Excel 2010 in a xlsm file. The function worked fine, but after I saved and re-opened the file, the values would switch from their calculated value to the &#8220;#VALUE!&#8221; error message. If I hit F2 on any of the cells and hit enter to recalculate, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-201","post","type-post","status-publish","format-standard","hentry","category-microsoft-excel"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=201"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/201\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}