https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/171719&feed=atom&action=history
Microsoft KB Archive/171719 - Revision history
2024-03-28T18:08:14Z
Revision history for this page on the wiki
MediaWiki 1.39.3
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/171719&diff=343790&oldid=prev
X010: Text replacement - """ to """
2020-07-21T10:06:06Z
<p>Text replacement - """ to """</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en-GB">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 10:06, 21 July 2020</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l85">Line 85:</td>
<td colspan="2" class="diff-lineno">Line 85:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When you use similar code in the Sub procedure, these error messages also appear. For example, the error messages appear when you run the following code in a Sub procedure:</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>When you use similar code in the Sub procedure, these error messages also appear. For example, the error messages appear when you run the following code in a Sub procedure:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre class="codesample"> Sub TrendError()</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre class="codesample"> Sub TrendError()</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Application.Trend(Worksheets(1).Range(<del style="font-weight: bold; text-decoration: none;">&quot;</del>A1:D1<del style="font-weight: bold; text-decoration: none;">&quot;</del>).Value, , _</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Application.Trend(Worksheets(1).Range(<ins style="font-weight: bold; text-decoration: none;">"</ins>A1:D1<ins style="font-weight: bold; text-decoration: none;">"</ins>).Value, , _</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> 5, True)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> 5, True)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> End Sub</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> End Sub</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l99">Line 99:</td>
<td colspan="2" class="diff-lineno">Line 99:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> NewXs = 5</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> NewXs = 5</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Result = Application.WorksheetFunction.Trend( _</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Result = Application.WorksheetFunction.Trend( _</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> Worksheets(1).Range(<del style="font-weight: bold; text-decoration: none;">&quot;</del>A1:D1<del style="font-weight: bold; text-decoration: none;">&quot;</del>).Value, , NewXs, True)</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> Worksheets(1).Range(<ins style="font-weight: bold; text-decoration: none;">"</ins>A1:D1<ins style="font-weight: bold; text-decoration: none;">"</ins>).Value, , NewXs, True)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Result(1)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Result(1)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l111">Line 111:</td>
<td colspan="2" class="diff-lineno">Line 111:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Dim NewXs as Single</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> Dim NewXs as Single</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> NewXs = 5</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> NewXs = 5</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> Result = Application.Trend(Worksheets(1).Range(<del style="font-weight: bold; text-decoration: none;">&quot;</del>A1:D1<del style="font-weight: bold; text-decoration: none;">&quot;</del>).Value, _</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> Result = Application.Trend(Worksheets(1).Range(<ins style="font-weight: bold; text-decoration: none;">"</ins>A1:D1<ins style="font-weight: bold; text-decoration: none;">"</ins>).Value, _</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> , NewXs, True)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> , NewXs, True)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Result(1)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> MsgBox Result(1)</div></td></tr>
</table>
X010
https://www.betaarchive.com/wiki/index.php?title=Microsoft_KB_Archive/171719&diff=90852&oldid=prev
3155ffGd: importing KB archive
2020-07-18T15:36:04Z
<p>importing KB archive</p>
<p><b>New page</b></p><div><div id="nsbanner"><br />
<br />
<div id="bannerrow1"><br />
<br />
{|<br />
| Knowledge Base<br />
|<br />
|}<br />
<br />
<br />
</div><br />
<div id="TitleRow"><br />
<br />
= <span id="KB171719"></span>TREND Function Works Differently in Functions Than in Macros =<br />
<br />
<br />
</div><br />
<br />
</div><br />
<div id="nstext" valign="BOTTOM"><br />
<br />
Article ID: 171719<br />
<br />
Article Last Modified on 8/17/2005<br />
<br />
<br />
-----<br />
<br />
APPLIES TO<br /><br />
<br /><br />
<br />
* Microsoft Excel 97 Standard Edition<br />
* Microsoft Excel 98 for Macintosh<br />
* Microsoft Excel 95 Standard Edition<br />
* Microsoft Excel 5.0 Standard Edition<br />
<br />
<br />
-----<br />
<br />
<div class="notice_section"><br />
<br />
This article was previously published under Q171719<br />
<br />
</div><br />
<div class="notice_section"><br />
<br />
<br />
<br />
</div><br />
<div class="summary_section"><br />
<br />
== SUMMARY ==<br />
<br />
When you use the Microsoft Excel TREND function in a Sub procedure in a Microsoft Visual Basic for Applications macro, the function behaves differently than when you use it in a custom function.<br /><br />
<br /><br />
This article explains how to use the TREND function in a Visual Basic Sub procedure.<br />
<br />
</div><br />
<div class="moreinformation_section"><br />
<br />
== MORE INFORMATION ==<br />
<br />
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. You can use the TREND function in a custom function like you do in a spreadsheet. For example, the following function works correctly when called by a formula in a worksheet:<br />
<pre class="codesample"> Function NewTrend(KnownYs, NewXs)<br />
<br />
NewTrend = Application.Trend(KnownYs, , NewXs, True)<br />
<br />
End Function<br />
</pre><br />
However, if this function is called by a subroutine in a module, one of the following error messages appears.<br />
=== Microsoft Excel 97 ===<br />
<br />
<div class="errormessage"><br />
<br />
Unable to get the Trend property of the WorksheetFunction class<br />
<br />
</div><br />
=== Microsoft Excel 5.0 and 7.0, Microsoft Excel 98 ===<br />
<br />
<div class="errormessage"><br />
<br />
Type mismatch<br />
<br />
</div><br />
When you use similar code in the Sub procedure, these error messages also appear. For example, the error messages appear when you run the following code in a Sub procedure:<br />
<pre class="codesample"> Sub TrendError()<br />
MsgBox Application.Trend(Worksheets(1).Range(&quot;A1:D1&quot;).Value, , _<br />
5, True)<br />
End Sub<br />
</pre><br />
=== Using the TREND Function in a Sub Procedure ===<br />
<br />
The methods in this article for using a TREND function in a Sub procedure require that the argument for new x's be passed as a Single or a Double data type. Note that the TREND function also returns an array and that it is necessary to pull the desired element to view the result of the function.<br /><br />
<br /><br />
Microsoft Excel 97: The following sample macro uses a TREND function in a Sub procedure in Microsoft Excel 97:<br />
<pre class="codesample"> Sub GoodTrend()<br />
<br />
Dim NewXs as Single<br />
NewXs = 5<br />
Result = Application.WorksheetFunction.Trend( _<br />
Worksheets(1).Range(&quot;A1:D1&quot;).Value, , NewXs, True)<br />
MsgBox Result(1)<br />
<br />
End Sub<br />
</pre><br />
Microsoft Excel 5.0 and 7.0 and Microsoft Excel 98:<br /><br />
<br /><br />
The following sample macro uses a TREND function in a Sub procedure in Microsoft Excel 5.0, 7.0, and 98:<br />
<pre class="codesample"> Sub GoodTrend()<br />
<br />
Dim NewXs as Single<br />
NewXs = 5<br />
Result = Application.Trend(Worksheets(1).Range(&quot;A1:D1&quot;).Value, _<br />
, NewXs, True)<br />
MsgBox Result(1)<br />
<br />
End Sub<br />
</pre><br />
NOTE: This macro works with horizontal or vertical ranges.<br />
<br />
</div><br />
<br /><br />
<br />
Additional query words: XL97 XL98 XL7 XL5 XL<br />
<br />
Keywords: kbinfo kbprogramming kbdtacode KB171719<br />
<br />
<div class="footer"><br />
<br />
<br /><br />
<br />
<br />
-----<br />
<br />
[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]<br />
<br />
<span>© Microsoft Corporation. All rights reserved.</span><br />
<br />
<br />
</div><br />
<br />
</div></div>
3155ffGd