<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/book_pages_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Microsoft Excel Tips / Excel Tutorial / Excel Spreadsheet Help / Excel Tip .com</title>
<!-- InstanceEndEditable --> 
<style><!--
.MsoBodyText
	{text-align:justify;
	line-height:14.0pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;}
.MsoBodyTextIndent
	{text-align:justify;
	line-height:14.0pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;
	font-weight:bold;}
.MsoBodyText2
	{text-align:justify;
	line-height:14.0pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;}
.listnumber
	{text-align:justify;
	line-height:14.0pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;}
.problemsolution
	{line-height:14.0pt;
	font-size:12.0pt;
	font-family:Arial;
	color:#636363;
	letter-spacing:.25pt;
	text-shadow:auto;
	font-weight:bold;}
.Chapter
	{text-align:center;
	font-size:20.0pt;
	font-family:Arial;
	letter-spacing:.25pt;
	text-shadow:auto;
	font-weight:bold;}
.HeaderEven
	{line-height:14.0pt;
	tab-stops:center 207.65pt right 415.3pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;}
.HeaderOdd
	{text-align:justify;
	line-height:14.0pt;
	tab-stops:center 207.65pt right 415.3pt;
	font-size:10.0pt;
	font-family:Arial;
	letter-spacing:.25pt;}
.Section1
	{page:Section1;}
.Section2
	{page:Section2;}
-->
</style>
<!-- \/--OPTIMIZATION BY: IRUBIN CONSULTING --------------------------------------------------\/ -->
<meta name="description" content="">
<meta name="keywords" content="">

<meta name="robots" content="all">
<meta name="revisit-after" content="15 days">
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.weburbia.com/safe/ratings.htm" l r (s 0))'>
<meta name="Classification" content="Microsoft Excel, Excel Spreadsheet, Excel Tips and Tricks, Microsoft Office">
<meta name="Copyright" content="2002 copyright">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<!-- /\------------------------------------------------------------/\ -->
<link rel="stylesheet" href="/css/main.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body bgcolor="#F79300" text="#333333" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--#include virtual="/cgi-bin/engine.pl?action=header"-->

<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td width="100%" valign="top" class="mtdleft">
	    <table border="0" cellspacing="0" cellpadding="0" align="right">
  <tr>
    <td >
              		  <object width="120" height="600">
              <param name="movie" value="/swf/exceltipflash_vertical.swf">
              <param name="quality" value="high">
              <embed src="/swf/exceltipflash_vertical.swf" quality="high" width="120" height="600"></embed>
			  </object> 
            </td>
  </tr>
</table>

	  <!-- InstanceBeginEditable name="Main Content Area" -->
	   <p align="center"><font class="chaptertitle">Chapter 7 continued ...</font><br>
        </p>
	<p class=head-2 ><a name="_Toc25863174"></a><a
name="_Toc26773961">Protecting Formulas in Cells</a></p>
<p > <img width=228 height=216
src="images/image057.jpg" align=left hspace=12 v:shapes="_x0000_s1363">
  Protecting a cell or a group of cells prevents writing, editing or deleting
  the cell, or damaging the formula. Two conditions must be met to protect a cell:
  the cell must be <b>locked</b>, and the sheet must be <b>protected.</b></p>
<p class=head-3 ><a name="_Toc25863175"></a><a
name="_Toc26773962">Locking, the first condition</a></p>
<p >Select a cell in the sheet and press <b>Ctrl+1</b>. In the <b>Format
  Cells </b>dialog box, select <b>Protection</b>. Select the <b>Locked</b> option.</p>
<p class=head-3 ><a name="_Toc25863176"></a><a name="_Toc26773963">Protecting
  a sheet, the second condition</a></p>
<p >From the <b>Tools </b>menu, select <b>Protection</b>, <b>Protect sheet</b>,
  and click <b>OK</b> (password is optional).</p>
<p class=head-3 ><a name="_Toc25863177"></a><a name="_Toc26773964">Protecting
  formulas</a></p>
<p class=HeaderOdd >Protecting formulas requires isolating cells with formulas
  from the rest of the cells in the sheet, locking them, and then protecting the
  sheet.</p>
<p class=head-5 >Stage 1  Canceling the locked format of all the cells
  in the sheet</p>
<p class=listnumber > 1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Select all the cells in the sheet by pressing <b>Ctrl+A</b>.</p>
<p class=listnumber > 2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Press <b>Ctrl+1</b>.</p>
<p class=listnumber > 3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Select the <b>Protection </b>tab.</p>
<p class=listnumber > 4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Clear the selection of the <b>locked</b> option.</p>
<p class=listnumber > 5.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Click <b>OK</b>.</p>
<p class=head-5 >Stage 2  Selecting cells with formulas</p>
<p class=listnumber > 1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Press <b>F5</b>.</p>
<p class=listnumber > 2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Click <b>Special</b>.</p>
<p class=listnumber > 3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Select the <b>Formulas</b> option.</p>
<p class=listnumber > 4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Click <b>OK</b>.</p>
<p class=head-5 >Stage 3  Locking cells with formulas</p>
<p class=listnumber > 1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Press <b>Ctrl+1</b>.</p>
<p class=listnumber > 2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Select the <b>Protection</b> tab.</p>
<p class=listnumber > 3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Select the <b>Locked</b> option.</p>
<p class=listnumber > 4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  Click <b>OK</b>.</p>
<p class=head-5 >Stage 4  Protecting the sheet</p>
<p class=listnumber > 1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  From the <b>Tools </b>menu, select <b>Protection, Protect sheet</b>.</p>
<p class=listnumber > 2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Click <b>OK</b> (password is optional).</p>
<div align=left >
  <table border=0 cellspacing=2 cellpadding=3 width=456>
    <tr bgcolor="#e0e0e0">
      <td width=180 valign=top class="Normal"> <p >The <b>Protect Sheet
          </b>dialog box in Excel 2002 allows you to select various topics for
          protection.</p>
        <p >In <b>Allow all users of this worksheet to</b> in the <b>Protect
          Sheet </b>dialog box, select the desired options<b>.</b></p></td>
            <td width=276 valign=top > <div align="right"><font color="#666666" size="3"><strong>New
                In <br>
                2002&nbsp;&nbsp;&nbsp;</strong></font> </div>
        <p > <img width=254 height=298
  src="images/image059.jpg" v:shapes="_x0000_i1046"> </p></td>
    </tr>
  </table></div>
	   <p align="center"><font class="chaptertitle">Chapter 7 continued ...</font><br>
        </p>
	<p class=head-2 ><a name="_Toc25863178"></a><a name="_Toc26773965">Displaying
  a Formula in a Cell and Printing Formulas</a></p>
<p class=head-3 ><a name="_Toc25863179"></a><a name="_Toc26773966">Displaying
  formula syntax</a></p>
<p >The result of calculating a formula (value) appears on the screen and
  can be printed by clicking the <b>Print</b> icon. However, you can usually view
  the syntax of a formula only by selecting the cell. To see all formulas on the
  sheet, press <b>Ctrl+~</b> (the ~ sign is located to the left of the number
  1 on the keyboard), or from the <b>Tools </b>menu, select <b>Options</b>. Then
  select the <b>View</b> tab, and select the <b>Formulas </b>option.</p>
<p >To return to the normal view, press <b>Ctrl+~ </b>again.</p>
<p class=head-3 ><a name="_Toc25863180"></a><a name="_Toc26773967">Printing
  the formula syntax</a></p>
<p >Use the usual method of printing in Excel to print from the sheet while
  formulas are displayed using <b>Ctrl+~</b>.</p>
<p > <img width=440 height=195
src="images/image061.gif" v:shapes="_x0000_i1047"> </p>
<br clear=all style='page-break-before:always'>
<p class=head-2 ><a name="_Toc25863181"></a><a name="_Toc26773968">Using
  VBA to Create and Add Functions to the Function Wizard</a></p>
<p >When you work in Excel, there will be times when you need to create
  a complex custom formula.</p>
<p class=HeaderOdd >Take, for example, a formula to calculate the net salary
  from a gross salary. This is a very complex calculation, as this type of formula
  is made up of fixed pieces of data, including income tax schedule, social security
  laws, tax credits and additional credits and deductions.</p>
<p >Another example would be a formula for calculating sales commission
  that varies depending on the level of sales, formulas for converting currency,
  conversion of weights and measures (a Convert function already exists in Excel),
  or a conversion of text. See <b>Chapter 16,</b> <b>Importing Text Files</b>.
</p>
<p >VBA formulas can be used for several reasons, one of which is to create
  custom functions for your personal use. You can add these functions to the <b>Function
  Wizard</b>.</p>
<p class=head-3 ><a name="_Toc25863182"></a><a name="_Toc26773969">Custom
  functions, example and explanation</a></p>
<p >Create a function called Add to total two numbers in different cells.
  The function has two argument boxes.</p>
<p > <img width=343 height=57
src="images/image062.gif" v:shapes="_x0000_i1048"> </p>
<p class=MsoBodyTextIndent >Formula structure:</p>
<p class=listbullet-1 > <span
style='font-family:"Wingdings 2"'>©<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span> Function name = Add</p>
<p class=listbullet-1 > <span
style='font-family:"Wingdings 2"'>©<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span> The function arguments are placed in parentheses. The above example
  has two argument boxes.</p>
<p class=listbullet-1 > <span
style='font-family:"Wingdings 2"'>©<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span> The last piece of the formula, As Integer, defines the value
  of the variables as a whole number. See the explanation in the <b>Variables</b>
  section of <b>Chapter 28, Other VBA Techniques.</b></p>
<p class=listbullet-1 > <span
style='font-family:"Wingdings 2"'>©<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span> Function calculation  where the function receives the results
  of the calculation and returns the result.</p>
<p class=MsoBodyTextIndent > 1.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Type numbers into cells A1:A2.</p>
<p class=listnumber > 2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Select cell A3 in the same sheet.</p>
<p class=listnumber > 3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Press <b>Shift+F3</b> (opens the <b>Paste Function</b> dialog box).</p>
<p class=listnumber > 4.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Select the <b>User Defined</b> category.</p>
<p class=listnumber > 5.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> Select the <b>Add</b> function.</p>
<p class=listnumber > 6.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> In the first argument box, select cell A1.</p>
<p class=listnumber > 7.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> In the second argument box, select cell A2.</p>
<p class=listnumber > 8.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span> <img width=192 height=160
src="images/image064.jpg" align=left hspace=12 v:shapes="_x0000_s1367">
  Click <b>OK</b>.</p>
<p class=listnumber > <img width=216 height=121
src="images/image066.jpg" v:shapes="_x0000_i1049"> </p>
<p class=head-3 ><a name="_Toc25863183"></a><a
name="_Toc26773970">Using a function to calculate accrued income tax from gross
  salary</a></p>
<p >This function will calculate the tax payable based on gross salary,
  marginal tax schedule and credit point schedule.</p>
<p >The function has a single edit box  gross salary (income).</p>
<p >Schedules  the values are defined using a constant variable, Const,
  which cannot be changed when the function is operating. The constant variables
  are loaded into memory cells when the function is operated.</p>
<p >Case  like IF, the function allows you to check a large number of
  instances.</p>
  <img
width=98 height=73 src="images/image067.gif" v:shapes="_x0000_s1373 _x0000_s1374 _x0000_s1375">
<img width=85 height=86
src="images/image068.gif" v:shapes="_x0000_s1370 _x0000_s1371 _x0000_s1372"><img
width=85 height=157 src="images/image069.gif" v:shapes="_x0000_s1379 _x0000_s1380 _x0000_s1381">
  <img
width=98 height=87 src="images/image070.gif" v:shapes="_x0000_s1376 _x0000_s1377 _x0000_s1378">
  <img width=362 height=435
src="images/image072.gif" v:shapes="_x0000_i1050">
  <p></p>
  <p > <img width=427 height=219
src="images/image074.jpg" v:shapes="_x0000_i1051">
  <p >&nbsp;</p>
      <p align="center"><a href="/excel_book/chapter7/p8.html">PREVIOUS</a> &nbsp;<a href="/excel_book/chapter7/p1.html">1</a>
        <a href="/excel_book/chapter7/p2.html">2</a> <a href="/excel_book/chapter7/p3.html">3</a>
        <a href="/excel_book/chapter7/p4.html">4</a> <a href="/excel_book/chapter7/p5.html">5</a>
        <a href="/excel_book/chapter7/p6.html">6</a> <a href="/excel_book/chapter7/p7.html">7</a>
        <a href="/excel_book/chapter7/p8.html">8</a> <a href="/excel_book/chapter7/p9.html">9</a>
        &nbsp;</p>


	<!-- InstanceEndEditable --> 
    </td>
	      
    <td valign="top" class="mtdright">
	
	<!--#include virtual="/cgi-bin/engine.pl?action=right_side"-->


	 </td>
  </tr>
</table>
<!--#include virtual="/cgi-bin/engine.pl?action=footer"-->


</body>
<!-- InstanceEnd --></html>
