{"id":1050,"date":"2013-12-07T06:32:58","date_gmt":"2013-12-07T06:32:58","guid":{"rendered":"http:\/\/excelvbatutor.com\/?page_id=1050"},"modified":"2018-10-03T06:08:17","modified_gmt":"2018-10-03T06:08:17","slug":"excel-vba-2010-lesson-4","status":"publish","type":"page","link":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/","title":{"rendered":"Excel  2010 VBA  Lesson 4: Operators"},"content":{"rendered":"<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-3-array\/\">[Lesson 3]<\/a>&lt;&lt;<a title=\"excel vba 2014 tutorial\" href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&gt;&gt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-5-writing-the-code\/\">[Lesson 5]<\/a><\/strong><\/h4>\n<p>Operators are important in writing Excel\u00a02010 VBA program code. They are used to compute values, perform certain operations, make comparisons and more. The operators can be divided into three main categories:<\/p>\n<ul>\n<li>Arithmetic<\/li>\n<li>Comparison<\/li>\n<li>Logical<\/li>\n<\/ul>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h3><strong>\u00a04.1 Arithmetic Operators<\/strong><\/h3>\n<p>Arithmetic operators are used to performing mathematical operations in Excel VBA 2010.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<th><strong>Operator<\/strong><\/th>\n<th><strong>Mathematical function<\/strong><\/th>\n<th><strong>Example<\/strong><\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">^<\/p>\n<\/td>\n<td>Exponential<\/td>\n<td>MsgBox 2^4 gives a value of 16<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">*<\/p>\n<\/td>\n<td>Multiplication<\/td>\n<td>MsgBox 4*3 gives a value of 12,<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">\/<\/p>\n<\/td>\n<td>Division<\/td>\n<td>MsgBox 12\/4 gives a value of 3<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Mod<\/p>\n<\/td>\n<td>Modulus (returns the remainder from an integer division)<\/td>\n<td>MsgBox 15 Mod 4 gives value of 3<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">\\<\/p>\n<\/td>\n<td>Integer Division(discards the decimal places)<\/td>\n<td>MsgBox 19\\4 gives a value of 4<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">+ or &amp;<\/p>\n<\/td>\n<td>String concatenation<\/td>\n<td>MsgBox &#8220;Excel&#8221;&amp;&#8221;VBA 2010&#8221; or &#8220;Excel&#8221;+&#8221;VBA 2010&#8221; produces a new string &#8220;Excel VBA 2010&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>*Note that MsgBox 1+&#8221;VBA&#8221; will produce a type mismatch error whereas MsgBox 1&amp;&#8221;VBA&#8221; will not result in an error, it gives a concatenated string 1VBA.<\/p>\n<p>We shall engage the use of arithmetic operators in Excel 2010 VBA code writing in future lessons.<\/p>\n<h3><strong>4.2 Comparison Operators<\/strong><\/h3>\n<p>Comparison operators are often used in writing code that requires decisions making. For example,<\/p>\n<pre style=\"font-size: 110%; width: 80%;\">If mark&gt;50 then\r\n MsgBox \"Pass\"\r\nElse\r\n MsgBox \"Fail\"\r\nEndif\r\n<\/pre>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><br \/>\nHere is a list of comparison operators:<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<th style=\"align: center;\">Operator<\/th>\n<th><strong>Meaning<\/strong><\/th>\n<th><strong>Example<\/strong><\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">&lt;<\/p>\n<\/td>\n<td>Less than<\/td>\n<td>MsgBox 2&lt;3 returns true while MsgBox 4&gt;5 returns false<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">&lt;=<\/p>\n<\/td>\n<td>Less than or equal to<\/td>\n<td>MsgBox 3&lt;=4 returns true<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">&gt;<\/p>\n<\/td>\n<td>Greater than<\/td>\n<td>MsgBox 5&gt;4 returns true<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">&gt;=<\/p>\n<\/td>\n<td>Greater than or equal to<\/td>\n<td>MsgBox 10&gt;=9 returns true<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">=<\/p>\n<\/td>\n<td>Equal to<\/td>\n<td>MsgBox 10=10 returns true<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">&lt;&gt;<\/p>\n<\/td>\n<td>Not Equal to<\/td>\n<td>MsgBox 9&lt;&gt;10 returns true<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>* For letters, the hierarchy is A&gt;B&gt;C&gt;&#8230;&#8230;&#8230;.&gt;Z<\/p>\n<p>Therefore MsgBox A&gt;B returns true<\/p>\n<h3><strong>4.3 Logical Operators<\/strong><\/h3>\n<p>Logical operators are also used in writing decision-making codes by comparing values or expressions.<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<th><strong>Operator <\/strong><\/th>\n<th><strong>Meaning<\/strong><\/th>\n<th><strong>Example<\/strong><\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">And<\/p>\n<\/td>\n<td>Logical Conjunction<\/td>\n<td>If A&gt;=80 And B&lt;101 thenGrade=&#8221;A&#8221;<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Or<\/p>\n<\/td>\n<td>Logical Disjunction<\/td>\n<td>If income&gt;5000 or car&gt;2 thenStatus=&#8221;Rich&#8221;<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Not<\/p>\n<\/td>\n<td>Logical negation<\/td>\n<td>MsgBox Not (3 &gt; 4)returns true<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"center\">Xor<\/p>\n<\/td>\n<td>Similar to Or, except that it returns False if both camparison values are true<\/td>\n<td>MsgBox 4 &gt; 3 Xor 5 &gt; 2\u00a0returns false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script><br \/>\n<ins class=\"adsbygoogle\" style=\"display: block; text-align: center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-3033628290023372\" data-ad-slot=\"9639157585\"><\/ins><br \/>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script><\/p>\n<h4 style=\"text-align: center;\"><strong><a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-3-array\/\">[Lesson 3]<\/a>&lt;&lt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-tutorial\/\">[Table of Contents]<\/a>&gt;&gt;<a href=\"http:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-5-writing-the-code\/\">[Lesson 5]<\/a><\/strong><\/h4>\n","protected":false},"excerpt":{"rendered":"<p>[Lesson 3]&lt;&lt;[Table of Contents]&gt;&gt;[Lesson 5] Operators are important in writing Excel\u00a02010 VBA program code. They are used to compute values, perform certain operations, make comparisons and more. The operators can be divided into three main categories: Arithmetic Comparison Logical \u00a04.1 Arithmetic Operators Arithmetic operators are used to performing mathematical operations in Excel VBA 2010. Operator &hellip; <a href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Excel  2010 VBA  Lesson 4: Operators&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5012,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-1050","page","type-page","status-publish","hentry","category-operators"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor<\/title>\n<meta name=\"description\" content=\"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"og:description\" content=\"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage\" \/>\n<meta property=\"og:url\" content=\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\" \/>\n<meta property=\"article:modified_time\" content=\"2018-10-03T06:08:17+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\",\"url\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\",\"name\":\"Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"isPartOf\":{\"@id\":\"https:\/\/excelvbatutor.com\/#website\"},\"datePublished\":\"2013-12-07T06:32:58+00:00\",\"dateModified\":\"2018-10-03T06:08:17+00:00\",\"description\":\"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage\",\"breadcrumb\":{\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/excelvbatutor.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel 2010 VBA Lesson 4: Operators\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/excelvbatutor.com\/#website\",\"url\":\"https:\/\/excelvbatutor.com\/\",\"name\":\"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor\",\"description\":\"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.\",\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/","og_locale":"en_US","og_type":"article","og_title":"Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","og_description":"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage","og_url":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/","og_site_name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","article_modified_time":"2018-10-03T06:08:17+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/","url":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/","name":"Excel 2010 VBA Lesson 4: Operators - Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","isPartOf":{"@id":"https:\/\/excelvbatutor.com\/#website"},"datePublished":"2013-12-07T06:32:58+00:00","dateModified":"2018-10-03T06:08:17+00:00","description":"This lessons illustrates different kinds of operators in Excel 2010 VBA and their usage","breadcrumb":{"@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/excelvbatutor.com\/index.php\/excel-vba-2010-lesson-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/excelvbatutor.com\/"},{"@type":"ListItem","position":2,"name":"Excel 2010 VBA Lesson 4: Operators"}]},{"@type":"WebSite","@id":"https:\/\/excelvbatutor.com\/#website","url":"https:\/\/excelvbatutor.com\/","name":"Learn Excel VBA Online \u2013 Step-by-Step Tutorials &amp; Courses | ExcelVBATutor","description":"Master Excel VBA with free tutorials, examples, and personalized guidance. Perfect for beginners and advanced users looking to automate Excel.","inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/users\/5012"}],"replies":[{"embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/comments?post=1050"}],"version-history":[{"count":57,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1050\/revisions"}],"predecessor-version":[{"id":3067,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/pages\/1050\/revisions\/3067"}],"wp:attachment":[{"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/media?parent=1050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/categories?post=1050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/excelvbatutor.com\/index.php\/wp-json\/wp\/v2\/tags?post=1050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}