{"id":2995,"date":"2020-02-12T12:30:59","date_gmt":"2020-02-12T12:30:59","guid":{"rendered":"https:\/\/www.mjtnet.com\/blog\/?p=2995"},"modified":"2020-02-12T12:44:46","modified_gmt":"2020-02-12T12:44:46","slug":"setting-cell-functions-in-excel-plus-a-sneak-peak","status":"publish","type":"post","link":"https:\/\/www.mjtnet.com\/blog\/2020\/02\/12\/setting-cell-functions-in-excel-plus-a-sneak-peak\/","title":{"rendered":"Setting cell functions in Excel, plus a sneak peak!"},"content":{"rendered":"<p>Something that often gets asks is &#8216;Can I insert a function into Excel&#8217; using <a href=\"https:\/\/www.mjtnet.com\/macro-scheduler.htm\">Macro Scheduler<\/a>&#8216;s native XL functions?&#8217;.<\/p>\n<p>Yes, you can. It may not be obvious from the <a href=\"https:\/\/manuals.mjtnet.com\/articles\/#!macro-scheduler-user-guide\/\">documentation<\/a> but with <a href=\"https:\/\/manuals.mjtnet.com\/articles\/#!macro-scheduler-user-guide\/xlgetcell\">XLSetCell<\/a> you can output any expression accepted by Excel. It doesn&#8217;t have to be a literal value.<\/p>\n<p>You might set a literal value with something like this:<\/p>\n<pre class=\"brush:macroscript\">\r\nXLSetCell>xlH,Sheet1,2,2,560,result\r\n<\/pre>\n<p><\/p>\n<p>In Excel you insert a function by starting the input with the &#8216;=&#8217; sign, so we can do the same with XLSetCell:<\/p>\n<pre class=\"brush:macroscript\">\r\nXLSetCell>xlH,Sheet1,20,2,=SUM(B1:B19),result\r\n<\/pre>\n<p><\/p>\n<p>In the same way we can force the cell to text format by preceding the input with an apostrophe:<\/p>\n<pre class=\"brush:macroscript\">\r\nXLSetCell>xlH,Sheet1,2,2,'560,result\r\n<\/pre>\n<p><\/p>\n<p>These formats are standard Excel features. All we&#8217;re doing here is passing a value to Excel that it understands. But you may not have realised you can do this with Macro Scheduler&#8217;s native functions.<\/p>\n<h1>Coming Soon &#8211; More functions &amp; run ANY VBA code!<\/h1>\n<p>A few people have requested more native XL functions. We&#8217;re working on it. <\/p>\n<p>For example, a new function to set the cell colour:<\/p>\n<pre class=\"brush:macroscript\">\r\nRGB>50,150,50,color1\r\nXLSetCellColor>xlH,Sheet1,13,2,color1\r\n<\/pre>\n<p><\/p>\n<h2>But how about being able to run <strong>ANY<\/strong> valid Excel VBA you like?<\/h2>\n<pre class=\"brush:macroscript\">\r\nXLRunVBA>xlH,ActiveSheet.Range(\"B12\").Interior.Color = vbRed\r\n<\/pre>\n<p><\/p>\n<p>It could be a whole block of code:<\/p>\n<pre class=\"brush:macroscript\">\r\nLabelToVar>vba_code,theCode\r\nXLRunVBA>xlH,theCode\r\n\r\n\/*\r\nvba_code:\r\n  Range(\"A1:B11\").Select\r\n  ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select\r\n  ActiveChart.SetSourceData Source:=Range(\"Sheet1!$A$1:$B$11\")\r\n  ActiveSheet.Shapes(\"Chart 1\").IncrementLeft +50\r\n  ActiveSheet.Shapes(\"Chart 1\").IncrementTop -30\r\n*\/\r\n<\/pre>\n<p><\/p>\n<p>These features are in development. Watch them in action here:<\/p>\n<p><iframe width=640 height=365 frameborder=\"0\" scrolling=\"no\" src=\"https:\/\/screencast-o-matic.com\/embed?sc=cYnllIwUcZ&#038;v=5&#038;ff=1\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>The sky is the limit!<\/p>\n<p>Note: At time of writing these functions do NOT exist in the current version. These are in development. Their names and syntax may change. Keep an eye out for updates.<\/p>\n<p>Be the first to get these new features by making sure your <a href=\"https:\/\/www.mjtnet.com\/ua.htm\">maintenance<\/a> or <a href=\"https:\/\/www.mjtnet.com\/subscriptions.htm\">subscription<\/a> us up to date \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something that often gets asks is &#8216;Can I insert a function into Excel&#8217; using Macro Scheduler&#8216;s native XL functions?&#8217;. Yes, you can. It may not be obvious from the documentation but with XLSetCell you can output any expression accepted by Excel. It doesn&#8217;t have to be a literal value. You might set a literal value [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2995"}],"collection":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/comments?post=2995"}],"version-history":[{"count":8,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2995\/revisions"}],"predecessor-version":[{"id":3003,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/posts\/2995\/revisions\/3003"}],"wp:attachment":[{"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/media?parent=2995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/categories?post=2995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mjtnet.com\/blog\/wp-json\/wp\/v2\/tags?post=2995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}