<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Excel Templates</title>
	<atom:link href="http://www.excely.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.excely.com</link>
	<description></description>
	<pubDate>Thu, 14 May 2009 06:41:33 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Ice Hockey World Cup 2009 Interactive Schedule</title>
		<link>http://www.excely.com/ice-hockey/world-cup-2009-schedule/</link>
		<comments>http://www.excely.com/ice-hockey/world-cup-2009-schedule/#comments</comments>
		<pubDate>Wed, 06 May 2009 11:00:40 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Ice Hockey]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=60</guid>
		<description><![CDATA[Ice Hockey World Cup 2009 Schedule in Excel incorporates a full calendar of all the finals of a 2009 Hockey World Cup Tournament that will take place on April 24 - May 10 in Zurich and Berne, Switzerland. As always, this product comes free of charge for your personal enjoyment.

 Track Hockey World Cup 2009 [...]]]></description>
			<content:encoded><![CDATA[<p>Ice Hockey World Cup 2009 Schedule in Excel incorporates a full calendar of all the finals of a 2009 Hockey World Cup Tournament that will take place on April 24 - May 10 in Zurich and Berne, Switzerland. As always, this product comes free of charge for your personal enjoyment.</p>
<p><span id="more-60"></span><br />
<a href="http://www.excely.com/download/hockeyworldcup2009.zip"><img title="Screenshot Ice Hockey World Cup Schedule" src="http://www.excely.com/images/world-cup-2009-schedule.png" border="0" alt="Screenshot Ice Hockey World Cup Schedule" hspace="0" vspace="0" align="right" /></a> Track Hockey <strong>World Cup 2009 Schedule</strong> with an advanced tool! Available in a form of an Excel spreadsheet, <strong>Ice Hockey World Cup 2009 Schedule</strong> helps you track the games by automatically calculating the performance of every team. Hockey World Cap 2009 Schedule helps you track teams that make it to the quarterfinal, semifinal and final without the use of macros. Just fill in the cells with the number of pucks scored by each team, and specify whether the game ended in regular time or overtime, and Track Hockey World Cap 2009 Schedule will calculate the results automatically, helping you to figure out the advancements made by each team. With all the technology available at your fingertips, you can make informed predictions, make better bets and amaze your friends with your knowledge of <strong>Hockey World Cup 2009</strong>.</p>
<p>Track Hockey World Cup 2009 Schedule is absolutely free for personal use. The calendar is available in English, German, French, Spanish, and Russian, and supports different time zones to help you figure out when exactly a match happens in your local time. Ice Hockey World Cup 2009 Schedule in Excel does not use Excel macros, and works safely and securely in every version of Microsoft Excel available.</p>
<h2 class="down"><a href="http://www.excely.com/download/hockeyworldcup2009.zip">Download World Cup 2009 Schedule</a></h2>
<p><a href="http://www.flesport.com/ice-hockey/world-cup-2009.html">Interactive schedule</a> (flash version)</p>
<p><strong style="color:red">UPDATE:</strong> Schedule has been fixed. Please download the latest version.<br />
We apologize for the inconvenience <img src='http://www.excely.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/ice-hockey/world-cup-2009-schedule/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using InputBox Method in Excel VBA</title>
		<link>http://www.excely.com/excel-vba/using-inputbox-method/</link>
		<comments>http://www.excely.com/excel-vba/using-inputbox-method/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 13:45:08 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=224</guid>
		<description><![CDATA[You can recieve a simple information from user using Message Box in your Excel VBA code: Yes / No / Cancel etc.
But to gather more specific information (formula, number, text, logical value or cell reference) from a user you need Application.InputBox method:

InputBox(Prompt[,Title][,Default][,x][,y][,HelpFile][,HelpContextId][,Type])

where Type specifies the return data type:


Type Values


0
Formula


1
Number


2
Text (String)


4
Logical value (True or False)


8
Cell reference [...]]]></description>
			<content:encoded><![CDATA[<p>You can recieve a simple information from user <a href="http://www.excely.com/excel-vba/using-message-box/" title="using Message Box" name="using Message Box">using Message Box</a> in your <a href="http://www.excely.com/excel-vba/" title="Excel VBA code" name="Excel VBA code">Excel VBA code</a>: <em>Yes</em> / <em>No</em> / <em>Cancel</em> etc.</p>
<p>But to gather more specific information (formula, number, text, logical value or cell reference) from a user you need <strong>Application.InputBox</strong> method:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">InputBox(Prompt[,Title][,Default][,x][,y][,HelpFile][,HelpContextId][,<span style="color: #000080;">Type</span>])</pre></div></div>

<p>where <strong>Type</strong> specifies the return data type:</p>
<table border="1px" width="400px" cellpadding="0" cellspacing="1px">
<tr align="center">
<td colspan="2"><b>Type Values</b></td>
</tr>
<tr align="center">
<td width="100px">0</td>
<td width="300px">Formula</td>
</tr>
<tr align="center">
<td width="100px">1</td>
<td width="300px">Number</td>
</tr>
<tr align="center">
<td width="100px">2</td>
<td width="300px">Text (String)</td>
</tr>
<tr align="center">
<td width="100px">4</td>
<td width="300px">Logical value (<strong>True</strong> or <strong>False</strong>)</td>
</tr>
<tr align="center">
<td width="100px">8</td>
<td width="300px">Cell reference (<a href="http://www.excely.com/excel-vba/range-object/" title="Range object" name="Range object">Range object</a>)</td>
</tr>
<tr align="center">
<td width="100px">16</td>
<td width="300px">Error value</td>
</tr>
<tr align="center">
<td width="100px">64</td>
<td width="300px">Array of values</td>
</tr>
</table>
<p>&nbsp;</p>
<p><strong>Example: <em>Using InputBox method in Excel</em></strong></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> TestInputBox()
    <span style="color: #000080;">Dim</span> myRange <span style="color: #000080;">As</span> Range
&nbsp;
    <span style="color: #000080;">Set</span> myRange = Application.InputBox(Prompt:= _
        &quot;Please <span style="color: #000080;">Select</span> a Range&quot;, _
        Title:=&quot;InputBox Method&quot;, <span style="color: #000080;">Type</span>:=8)
&nbsp;
    <span style="color: #000080;">If</span> myRange <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span> <span style="color: #000080;">Then</span>
        <span style="color: #008000;">' Range is blank
</span>    <span style="color: #000080;">Else</span>
        myRange.<span style="color: #000080;">Select</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/using-inputbox-method/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Custom Message Box Buttons using Hooking in Excel VBA</title>
		<link>http://www.excely.com/excel-vba/change-message-box-buttons/</link>
		<comments>http://www.excely.com/excel-vba/change-message-box-buttons/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 14:43:07 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=233</guid>
		<description><![CDATA[Q. How can I change the button caption for the Message Box (MsgBox)?
A. You need to use Windows Hooking API in your Excel VBA:

You must create a CBT hook
Run a Message Box with CBT hook
Catch a HCBT_ACTIVATE message in the Hook procedure
Set new cputions for the buttons using the SetDlgItemText function(example below changes &#8220;Yes&#8221; and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Q. How can I change the button caption for the <a href="http://www.excely.com/excel-vba/using-message-box/" title="Message Box" name="Message Box">Message Box</a> (MsgBox)?</strong></p>
<p><strong>A.</strong> You need to use Windows Hooking API in your <a href="http://www.excely.com/excel-vba/" title="Excel VBA" name="Excel VBA">Excel VBA</a>:</p>
<ul>
<li>You must create a <em>CBT hook</em></li>
<li>Run a Message Box with <em>CBT hook</em></li>
<li>Catch a <em>HCBT_ACTIVATE</em> message in the Hook procedure</li>
<li>Set new cputions for the buttons using the <em>SetDlgItemText</em> function<br />(example below changes &#8220;Yes&#8221; and &#8220;No&#8221; captions to smiles: &#8220;:-)&#8221; and &#8220;:-(&#8221; )</li>
<li>Release the <em>CBT hook</em></li>
</ul>
<p><strong>Example: <em>Change Button Captions for Message Box using VBA in Excel</em></strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span>
&nbsp;
<span style="color: #008000;">' Import
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> GetCurrentThreadId <span style="color: #000080;">Lib</span> &quot;kernel32&quot; () <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> SetDlgItemText <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    <span style="color: #000080;">Alias</span> &quot;SetDlgItemTextA&quot; _
    (<span style="color: #000080;">ByVal</span> hDlg <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> nIDDlgItem <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> lpString <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> SetWindowsHookEx <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    <span style="color: #000080;">Alias</span> &quot;SetWindowsHookExA&quot; _
    (<span style="color: #000080;">ByVal</span> idHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> lpfn <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> hmod <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> dwThreadId <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> UnhookWindowsHookEx <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    (<span style="color: #000080;">ByVal</span> hHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #008000;">' Handle to the Hook procedure
</span><span style="color: #000080;">Private</span> hHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #008000;">' Hook type
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> WH_CBT = 5
<span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> HCBT_ACTIVATE = 5
&nbsp;
<span style="color: #008000;">' Constants
</span><span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDOK = 1
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDCANCEL = 2
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDABORT = 3
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDRETRY = 4
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDIGNORE = 5
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDYES = 6
<span style="color: #000080;">Public</span> <span style="color: #000080;">Const</span> IDNO = 7
&nbsp;
<span style="color: #000080;">Public</span> <span style="color: #000080;">Sub</span> MsgBoxSmile()
    <span style="color: #008000;">' Set Hook
</span>    hHook = SetWindowsHookEx(WH_CBT, _
                             <span style="color: #000080;">AddressOf</span> MsgBoxHookProc, _
                             0, _
                             GetCurrentThreadId)
&nbsp;
    <span style="color: #008000;">' Run MessageBox
</span>    MsgBox &quot;Smiling Message Box&quot;, vbYesNo, &quot;Message Box Hooking&quot;
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> MsgBoxHookProc(<span style="color: #000080;">ByVal</span> lMsg <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
                                <span style="color: #000080;">ByVal</span> wParam <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
                                <span style="color: #000080;">ByVal</span> lParam <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
    <span style="color: #000080;">If</span> lMsg = HCBT_ACTIVATE <span style="color: #000080;">Then</span>
        SetDlgItemText wParam, IDYES, &quot;:-)&quot;
        SetDlgItemText wParam, IDNO, &quot;:-(&quot;
&nbsp;
        <span style="color: #008000;">' Release the Hook
</span>        UnhookWindowsHookEx hHook
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    MsgBoxHookProc = <span style="color: #000080;">False</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/change-message-box-buttons/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Define a Position of MessageBox using VBA in Excel</title>
		<link>http://www.excely.com/excel-vba/define-a-position-of-messagebox/</link>
		<comments>http://www.excely.com/excel-vba/define-a-position-of-messagebox/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 09:26:29 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=222</guid>
		<description><![CDATA[Typical MsgBox pops-up in the center of the screen. You can change MsgBox&#8217;s position using a Hooking API in your VBA code:

You must create a CBT hook
Run a Message Box with CBT hook
Catch a HCBT_ACTIVATE message in the Hook procedure
Set new position using the SetWindowPos function
Release the CBT hook

Example: Hooking MessageBox using VBA in Excel:

Option [...]]]></description>
			<content:encoded><![CDATA[<p>Typical <a href="http://www.excely.com/excel-vba/using-message-box/" title="MsgBox" name="MsgBox">MsgBox</a> pops-up in the center of the screen. You can change MsgBox&#8217;s position using a Hooking API in your <a href="http://www.excely.com/excel-vba/" title="VBA code" name="VBA code">VBA code</a>:</p>
<ul>
<li>You must create a <em>CBT hook</em></li>
<li>Run a Message Box with <em>CBT hook</em></li>
<li>Catch a <em>HCBT_ACTIVATE</em> message in the Hook procedure</li>
<li>Set new position using the <em>SetWindowPos</em> function</li>
<li>Release the <em>CBT hook</em></li>
</ul>
<p><strong>Example: <em>Hooking MessageBox using VBA in Excel</em></strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span>
&nbsp;
<span style="color: #008000;">' Import
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> UnhookWindowsHookEx <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    (<span style="color: #000080;">ByVal</span> hHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> GetCurrentThreadId <span style="color: #000080;">Lib</span> &quot;kernel32&quot; () <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> SetWindowsHookEx <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    <span style="color: #000080;">Alias</span> &quot;SetWindowsHookExA&quot; _
    (<span style="color: #000080;">ByVal</span> idHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> lpfn <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> hmod <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> dwThreadId <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Declare</span> <span style="color: #000080;">Function</span> SetWindowPos <span style="color: #000080;">Lib</span> &quot;user32&quot; _
    (<span style="color: #000080;">ByVal</span> hwnd <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> hWndInsertAfter <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> x <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> y <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> cx <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> cy <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
     <span style="color: #000080;">ByVal</span> wFlags <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #008000;">' Handle to the Hook procedure
</span><span style="color: #000080;">Private</span> hHook <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #008000;">' Position
</span><span style="color: #000080;">Private</span> msgbox_x <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
<span style="color: #000080;">Private</span> msgbox_y <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
&nbsp;
<span style="color: #008000;">' Hook type
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> WH_CBT = 5
<span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> HCBT_ACTIVATE = 5
&nbsp;
<span style="color: #008000;">' SetWindowPos Flags
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> SWP_NOSIZE = &amp;H1      <span style="color: #008000;">' Retains the current size
</span><span style="color: #000080;">Private</span> <span style="color: #000080;">Const</span> SWP_NOZORDER = &amp;H4    <span style="color: #008000;">' Retains the current Z order
</span>
<span style="color: #000080;">Sub</span> TestMsgBox()
    MsgBoxPos &quot;Set non-Center Position&quot;, _
              vbOKOnly, _
              &quot;Message Box Hooking&quot;, _
              400, 300
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
<span style="color: #000080;">Public</span> <span style="color: #000080;">Sub</span> MsgBoxPos(strPromt <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, _
              vbButtons <span style="color: #000080;">As</span> VbMsgBoxStyle, _
              strTitle <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, _
              xPos <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
              yPos <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>)
&nbsp;
    <span style="color: #008000;">' Store position
</span>    msgbox_x = xPos
    msgbox_y = yPos
&nbsp;
    <span style="color: #008000;">' Set Hook
</span>    hHook = SetWindowsHookEx(WH_CBT, _
                              <span style="color: #000080;">AddressOf</span> MsgBoxHookProc, _
                              0, _
                              GetCurrentThreadId)
&nbsp;
    <span style="color: #008000;">' Run MessageBox
</span>    MsgBox strPromt, vbButtons, strTitle
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> MsgBoxHookProc(<span style="color: #000080;">ByVal</span> lMsg <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
                                <span style="color: #000080;">ByVal</span> wParam <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>, _
                                <span style="color: #000080;">ByVal</span> lParam <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Long</span>
    <span style="color: #000080;">If</span> lMsg = HCBT_ACTIVATE <span style="color: #000080;">Then</span>
        <span style="color: #008000;">' Change position
</span>        SetWindowPos wParam, 0, msgbox_x, msgbox_y, _
                     0, 0, SWP_NOSIZE + SWP_NOZORDER
&nbsp;
        <span style="color: #008000;">' Release the Hook
</span>        UnhookWindowsHookEx hHook
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    MsgBoxHookProc = <span style="color: #000080;">False</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/define-a-position-of-messagebox/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Message Box (MsgBox) in Excel VBA</title>
		<link>http://www.excely.com/excel-vba/using-message-box/</link>
		<comments>http://www.excely.com/excel-vba/using-message-box/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 14:06:06 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=206</guid>
		<description><![CDATA[MsgBox function in VBA displays a message in a window and waits for click on a button.
Example of using Yes-No Message Box:

Sub MessageBoxExample()
    Dim iRet As Integer
    Dim strPrompt As String
    Dim strTitle As String
&#160;
    ' Promt
    strPrompt = &#34;Ask [...]]]></description>
			<content:encoded><![CDATA[<p><strong>MsgBox</strong> function in <a href="http://www.excely.com/excel-vba/" title="VBA" name="VBA">VBA</a> displays a message in a window and waits for click on a button.</p>
<p>Example of using Yes-No <strong>Message Box</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> MessageBoxExample()
    <span style="color: #000080;">Dim</span> iRet <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
    <span style="color: #000080;">Dim</span> strPrompt <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
    <span style="color: #000080;">Dim</span> strTitle <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
    <span style="color: #008000;">' Promt
</span>    strPrompt = &quot;Ask Your Question Here, OK?&quot;
&nbsp;
    <span style="color: #008000;">' Dialog's Title
</span>    strTitle = &quot;My Tite&quot;
&nbsp;
    <span style="color: #008000;">'Display MessageBox
</span>    iRet = MsgBox(strPrompt, vbYesNo, strTitle)
&nbsp;
    <span style="color: #008000;">' Check pressed button
</span>    <span style="color: #000080;">If</span> iRet = vbNo <span style="color: #000080;">Then</span>
        MsgBox &quot;NO!&quot;
    <span style="color: #000080;">Else</span>
        MsgBox &quot;Yes!&quot;
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p><strong>Message Box</strong> returns an integer value to indicate clicked button (Yes, No, Cancel, etc.):</p>
<table border="1px" width="300px" cellpadding="0" cellspacing="1px">
<tr align="center">
<td colspan="3"><b>Return Values</b></td>
</tr>
<tr align="center">
<td width="100px">1</td>
<td width="100px">OK</td>
<td width="100px">vbOk</td>
</tr>
<tr align="center">
<td width="100px">2</td>
<td width="100px">Cancel</td>
<td width="100px">vbCancel</td>
</tr>
<tr align="center">
<td width="100px">3</td>
<td width="100px">Abort</td>
<td width="100px">vbAbort</td>
</tr>
<tr align="center">
<td width="100px">4</td>
<td width="100px">Retry</td>
<td width="100px">vbRetry</td>
</tr>
<tr align="center">
<td width="100px">5</td>
<td width="100px">Ignore</td>
<td width="100px">vbIgnore</td>
</tr>
<tr align="center">
<td width="100px">6</td>
<td width="100px">Yes</td>
<td width="100px">vbYes</td>
</tr>
<tr align="center">
<td width="100px">7</td>
<td width="100px">No</td>
<td width="100px">vbNo</td>
</tr>
</table>
<p>You can specify the number and type of buttons of <strong>Message Box</strong> (the default value for buttons is 0 - display OK button only):</p>
<table border="1px" width="500px" cellpadding="0" cellspacing="1px">
<tr align="center">
<td colspan="3"><b>Type of Buttons</b></td>
</tr>
<tr align="center">
<td width="100px">0</td>
<td width="100px">vbOKOnly</td>
<td width="300px">OK button only</td>
</tr>
<tr align="center">
<td width="100px">1</td>
<td width="100px">vbOKCancel</td>
<td width="300px">OK and Cancel buttons</td>
</tr>
<tr align="center">
<td width="100px">2</td>
<td width="100px">vbAbortRetryIgnore</td>
<td width="300px">Abort, Retry, and Ignore buttons</td>
</tr>
<tr align="center">
<td width="100px">3</td>
<td width="100px">vbYesNoCancel</td>
<td width="300px">Yes, No, and Cancel buttons</td>
</tr>
<tr align="center">
<td width="100px">4</td>
<td width="100px">vbYesNo</td>
<td width="300px">Yes and No buttons</td>
</tr>
<tr align="center">
<td width="100px">5</td>
<td width="100px">vbRetryCancel</td>
<td width="300px">Retry and Cancel buttons</td>
</tr>
</table>
<p>Related articles:</p>
<ul>
<li><a href="http://www.excely.com/excel-vba/define-a-position-of-messagebox/" title="Hooking MessageBox using VBA in Excel" name="Hooking MessageBox using VBA in Excel">Hooking MessageBox using VBA in Excel</a></li>
<li><a href="http://www.excely.com/excel-vba/change-message-box-buttons/" title="Custom MsgBox Buttons using VBA in Excel" name="Custom MsgBox Buttons using VBA in Excel">Custom MsgBox Buttons using VBA in Excel</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/using-message-box/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Using Intersection to Create a Range in Excel VBA</title>
		<link>http://www.excely.com/excel-vba/using-intersection-to-create-a-range/</link>
		<comments>http://www.excely.com/excel-vba/using-intersection-to-create-a-range/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 13:11:40 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=185</guid>
		<description><![CDATA[Intersect Method returns a Range object that represents the Intersection of Ranges.
Example selects the Intersection of 2 Ranges (A1:D5 and C3:C10). If the Intersection is blank, the example displays a message box:

Private Sub UseIntersection()
    IntersectRanges Range(&#34;A1:D5&#34;), Range(&#34;C3:C10&#34;)
End Sub
&#160;
Private Sub IntersectRanges(range1 As Range, range2 As Range)
    Dim intRange As Range
&#160;
 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Intersect</strong> Method returns a <a href="http://www.excely.com/excel-vba/range-object/" title="Range Object" name="Range Object">Range object</a> that represents the <strong>Intersection</strong> of Ranges.</p>
<p>Example selects the Intersection of 2 Ranges (A1:D5 and C3:C10). If the Intersection is blank, the example displays a <a href="http://www.excely.com/excel-vba/using-message-box/" title="Message Box" name="Message Box">message box</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> UseIntersection()
    IntersectRanges Range(&quot;A1:D5&quot;), Range(&quot;C3:C10&quot;)
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> IntersectRanges(range1 <span style="color: #000080;">As</span> Range, range2 <span style="color: #000080;">As</span> Range)
    <span style="color: #000080;">Dim</span> intRange <span style="color: #000080;">As</span> Range
&nbsp;
    <span style="color: #008000;">' Application.Intersect Method
</span>    <span style="color: #000080;">Set</span> intRange = Application.Intersect(range1, range2)
&nbsp;
    <span style="color: #000080;">If</span> intRange <span style="color: #000080;">Is</span> <span style="color: #000080;">Nothing</span> <span style="color: #000080;">Then</span>
        <span style="color: #008000;">' No Intersection
</span>        MsgBox &quot;Ranges <span style="color: #000080;">Do</span> <span style="color: #000080;">Not</span> Intersect!&quot;
    <span style="color: #000080;">Else</span>
        <span style="color: #008000;">' Show new Range's address
</span>        MsgBox (intRange.Address)
&nbsp;
        <span style="color: #008000;">' Select new Range
</span>        intRange.<span style="color: #000080;">Select</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/using-intersection-to-create-a-range/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Range Object in VBA</title>
		<link>http://www.excely.com/excel-vba/range-object/</link>
		<comments>http://www.excely.com/excel-vba/range-object/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 13:53:05 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=184</guid>
		<description><![CDATA[The Range Object is the object you will use most within your Excel VBA. Before you can manipulate any region within Excel, you must express it as a Range object:

Dim myRange As Range
Set myRange = ActiveSheet.Range(&#34;A1&#34;)

and work with methods and properties of that range:

myRange.Delete Shift:=xlUp

A Range object represents a cell, a row, a column, a [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>Range Object</strong> is the object you will use most within your <a href="http://www.excely.com/excel-vba/" title="Excel VBA" name="Excel VBA">Excel VBA</a>. Before you can manipulate any region within Excel, you must express it as a <strong>Range object</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> myRange <span style="color: #000080;">As</span> Range
<span style="color: #000080;">Set</span> myRange = ActiveSheet.Range(&quot;A1&quot;)</pre></div></div>

<p>and work with methods and properties of that range:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">myRange.Delete Shift:=xlUp</pre></div></div>

<p>A Range object represents a cell, a row, a column, a selection of cells containing one or more blocks of cells or even a group of cells on multiple sheets:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">' Cells
</span><span style="color: #000080;">Set</span> myRange = ActiveSheet.Range(&quot;A1:D5&quot;)
&nbsp;
<span style="color: #008000;">' Row
</span><span style="color: #000080;">Set</span> myRange = ActiveSheet.Rows(1)
&nbsp;
<span style="color: #008000;">' Column
</span><span style="color: #000080;">Set</span> myRange = ActiveSheet.Columns(2)
&nbsp;
<span style="color: #008000;">' Group of Cells
</span><span style="color: #000080;">Set</span> myRange = Application.Union( _ 
    ActiveSheet.Range(&quot;A1:D1&quot;), _
    ActiveSheet.Range(&quot;C3:C5&quot;))
&nbsp;
<span style="color: #008000;">' Select method
</span>myRange.<span style="color: #000080;">Select</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/range-object/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How To Store Current Range Selection using VBA in Excel?</title>
		<link>http://www.excely.com/excel-vba/how-to-store-current-range-selection/</link>
		<comments>http://www.excely.com/excel-vba/how-to-store-current-range-selection/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:38:02 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=152</guid>
		<description><![CDATA[Q. How To Store Current Selection using VBA in Excel?
A. Use the foloowing VBA script:

Option Explicit
Private Sub Example()
    Dim ActSheet As Worksheet
    Dim SelRange As Range
&#160;
    Set ActSheet = ActiveSheet
    Set SelRange = Selection
&#160;
    '' Any code here
   [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Q. How To Store Current Selection using VBA in Excel?</em></strong></p>
<p><strong>A.</strong> Use the foloowing <a href="http://www.excely.com/excel-vba/" title="VBA script" name="VBA script">VBA script</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span>
<span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> Example()
    <span style="color: #000080;">Dim</span> ActSheet <span style="color: #000080;">As</span> Worksheet
    <span style="color: #000080;">Dim</span> SelRange <span style="color: #000080;">As</span> Range
&nbsp;
    <span style="color: #000080;">Set</span> ActSheet = ActiveSheet
    <span style="color: #000080;">Set</span> SelRange = Selection
&nbsp;
    <span style="color: #008000;">'' Any code here
</span>    <span style="color: #008000;">'Dim NewSheet As Worksheet
</span>    <span style="color: #008000;">'
</span>    <span style="color: #008000;">'ActiveSheet.Range(&quot;A1&quot;).Select
</span>    <span style="color: #008000;">'
</span>    <span style="color: #008000;">'Set NewSheet = ThisWorkbook.Sheets().Add()
</span>    <span style="color: #008000;">'NewSheet.Move After:=Sheets(ThisWorkbook.Sheets().Count)
</span>
    ActSheet.<span style="color: #000080;">Select</span>
    SelRange.<span style="color: #000080;">Select</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>Let&#8217;s discuss how it works. First, <a href="http://www.excely.com/excel-vba/option-explicit-statement/" title="force explicit declaration" name="force explicit declaration">force explicit declaration</a> of all variables:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span></pre></div></div>

<p>To store selection we need two variables (<strong>Worksheet</strong> and <strong>Range</strong>):</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> ActSheet <span style="color: #000080;">As</span> Worksheet
<span style="color: #000080;">Dim</span> SelRange <span style="color: #000080;">As</span> Range</pre></div></div>

<p>Then we store active <strong>Worksheet</strong> and current <strong>range selection</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Set</span> ActSheet = ActiveSheet
<span style="color: #000080;">Set</span> SelRange = Selection</pre></div></div>

<p>Now we can use any VBA code (add new sheets, select or hide cells etc) and then restore origin <strong>selection</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">ActSheet.<span style="color: #000080;">Select</span>
SelRange.<span style="color: #000080;">Select</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/how-to-store-current-range-selection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Option Explicit Statement in VBA</title>
		<link>http://www.excely.com/excel-vba/option-explicit-statement/</link>
		<comments>http://www.excely.com/excel-vba/option-explicit-statement/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:02:15 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=138</guid>
		<description><![CDATA[Q. How to avoid incorrectly typing the name of an existing variable?
A. Use Option Explicit statement at file level to force explicit declaration of all variables in the script:

Option Explicit

Option Explicit statement must appear in a script before any procedures.
When you use the Option Explicit statement, you must explicitly declare all variables using the Dim, [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Q. How to avoid incorrectly typing the name of an existing variable?</em></strong></p>
<p><strong>A.</strong> Use <strong>Option Explicit</strong> statement at file level to force explicit declaration of all variables in the script:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Option</span> <span style="color: #000080;">Explicit</span></pre></div></div>

<p><strong>Option Explicit</strong> statement must appear in a script before any procedures.</p>
<p>When you use the <strong>Option Explicit</strong> statement, you must explicitly declare all variables using the <strong>Dim</strong>, <strong>Private</strong>, <strong>Public</strong>, or <strong>ReDim</strong> statements. If you attempt to use an undeclared variable name, an error occurs:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> myVar
myVar = 1
myNewVar = 0	' <span style="color: #000080;">ERROR</span>: Variable <span style="color: #000080;">not</span> defined.</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/option-explicit-statement/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Save Workbook as New File using VBA in Excel</title>
		<link>http://www.excely.com/excel-vba/save-workbook-as-new-file/</link>
		<comments>http://www.excely.com/excel-vba/save-workbook-as-new-file/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 09:32:20 +0000</pubDate>
		<dc:creator>Excel Trick</dc:creator>
		
		<category><![CDATA[Excel VBA]]></category>

		<guid isPermaLink="false">http://www.excely.com/?p=98</guid>
		<description><![CDATA[Q. How Save Workbook as New File? 
A. Use the following VBA code:

Private Sub SaveWorkbookAsNewFile(NewFileName As String)
    Dim ActSheet As Worksheet
    Dim ActBook As Workbook
    Dim CurrentFile As String
    Dim NewFileType As String
    Dim NewFile As String
&#160;
    [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Q. How Save Workbook as New File?</em></strong> </p>
<p><strong>A.</strong> Use the following <a href="http://www.excely.com/excel-vba/" title="VBA code" name="VBA code">VBA code</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> SaveWorkbookAsNewFile(NewFileName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)
    <span style="color: #000080;">Dim</span> ActSheet <span style="color: #000080;">As</span> Worksheet
    <span style="color: #000080;">Dim</span> ActBook <span style="color: #000080;">As</span> Workbook
    <span style="color: #000080;">Dim</span> CurrentFile <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
    <span style="color: #000080;">Dim</span> NewFileType <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
    <span style="color: #000080;">Dim</span> NewFile <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
    Application.ScreenUpdating = <span style="color: #000080;">False</span>    <span style="color: #008000;">' Prevents screen refreshing.
</span>    
    CurrentFile = ThisWorkbook.FullName
&nbsp;
    NewFileType = &quot;Excel Files 1997-2003 (*.xls), *.xls,&quot; &amp; _
               &quot;Excel Files 2007 (*.xlsx), *.xlsx,&quot; &amp; _
               &quot;All files (*.*), *.*&quot;
&nbsp;
    NewFile = Application.GetSaveAsFilename( _
        InitialFileName:=NewFileName, _
        fileFilter:=NewFileType)
&nbsp;
    <span style="color: #000080;">If</span> NewFile &lt;&gt; &quot;&quot; <span style="color: #000080;">And</span> NewFile &lt;&gt; &quot;False&quot; <span style="color: #000080;">Then</span>
        ActiveWorkbook.SaveAs Filename:= NewFile, _
            FileFormat:=xlNormal, _
            Password:=&quot;&quot;, _
            WriteResPassword:=&quot;&quot;, _
            ReadOnlyRecommended:=<span style="color: #000080;">False</span>, _
            CreateBackup:=<span style="color: #000080;">False</span>
&nbsp;
        <span style="color: #000080;">Set</span> ActBook = ActiveWorkbook
        Workbooks.<span style="color: #000080;">Open</span> CurrentFile
        ActBook.<span style="color: #000080;">Close</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
    Application.ScreenUpdating = <span style="color: #000080;">True</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>How does it work? Let&#8217;s look inside.</p>
<p>First, turn off <a href="http://www.excely.com/excel-vba/screen-updating-using-vba-in-excel/" title="screen updating" name="screen updating">screen updating</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Application.ScreenUpdating = <span style="color: #000080;">False</span></pre></div></div>

<p>Store the opened file full path:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">CurrentFile = ThisWorkbook.FullName</pre></div></div>

<p>Open window to choose new filename and folder:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">NewFile = Application.GetSaveAsFilename( _
    InitialFileName:=NewFileName, _
    fileFilter:=NewFileType)</pre></div></div>

<p>And now save file as new Workbook:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">ActiveWorkbook.SaveAs Filename:= NewFile, _
    FileFormat:=xlNormal, _
    Password:=&quot;&quot;, _
    WriteResPassword:=&quot;&quot;, _
    ReadOnlyRecommended:=<span style="color: #000080;">False</span>, _
    CreateBackup:=<span style="color: #000080;">False</span></pre></div></div>

<p>We have to close new file and open the origin workbook:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Set</span> ActBook = ActiveWorkbook
Workbooks.<span style="color: #000080;">Open</span> CurrentFile
ActBook.<span style="color: #000080;">Close</span></pre></div></div>

<p>and turn on <a href="http://www.excely.com/excel-vba/screen-updating-using-vba-in-excel/" title="screen updating" name="screen updating">screen updating</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Application.ScreenUpdating = <span style="color: #000080;">True</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.excely.com/excel-vba/save-workbook-as-new-file/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
